Skip to content

Commit 0a4f014

Browse files
committed
temp
1 parent 0c9c65e commit 0a4f014

File tree

3 files changed

+62
-29
lines changed

3 files changed

+62
-29
lines changed

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export async function activate(context: vscode.ExtensionContext)
6868
context.subscriptions.push(new CodeAnalyticsView(analyticsProvider, documentInfoProvider,
6969
context.extensionUri, editorHelper, workspaceState, codeLensProvider, envStatusbar, environmentManager,spanLinkResolver, documentInfoCache));
7070
context.subscriptions.push(new ErrorsLineDecorator(documentInfoProvider));
71-
context.subscriptions.push(new PerformanceDecorator(documentInfoProvider));
71+
context.subscriptions.push(new PerformanceDecorator(documentInfoProvider,workspaceState ));
7272
context.subscriptions.push(new HotspotMarkerDecorator(documentInfoProvider));
7373
context.subscriptions.push(new VsCodeDebugInstrumentation(analyticsProvider));
7474

src/views/codeAnalytics/codeAnalyticsView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ class CodeAnalyticsViewProvider implements vscode.WebviewViewProvider,vscode.Dis
445445
this._overlay.hide();
446446
}
447447
this._currentCodeObject = codeObject;
448-
vscode.commands.executeCommand(PerformanceDecorator.Commands.Show);
448+
// await vscode.commands.executeCommand(PerformanceDecorator.Commands.Show);
449449

450450

451451
}

src/views/codeAnalytics/decorators/performanceDecorator.ts

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from 'vscode';
22
import { DocumentInfoProvider, LineInfo } from '../../../services/documentInfoProvider';
33
import { WorkspaceState } from '../../../state';
4+
import { SpanDurationsInsight } from '../InsightListView/SpanInsight';
45

56
export class PerformanceDecorator implements vscode.Disposable
67
{
@@ -13,7 +14,9 @@ export class PerformanceDecorator implements vscode.Disposable
1314
private _textDecorationType: vscode.TextEditorDecorationType;
1415
private _disposables: vscode.Disposable[] = [];
1516

16-
constructor(private _documentInfoProvider: DocumentInfoProvider)
17+
constructor(private _documentInfoProvider: DocumentInfoProvider,
18+
private _workspaceState: WorkspaceState
19+
)
1720
{
1821
this._iconDecorationType = vscode.window.createTextEditorDecorationType({
1922
after:{
@@ -34,11 +37,9 @@ export class PerformanceDecorator implements vscode.Disposable
3437
this._disposables.push(vscode.commands.registerCommand(PerformanceDecorator.Commands.Hide, this.onHide.bind(this)));
3538
}
3639

37-
private async onShow(codeObjectId?: string)
40+
private async onShow()
3841
{
39-
if(!codeObjectId)
40-
return;
41-
42+
4243
const editor = vscode.window.activeTextEditor;
4344
if(!editor)
4445
return;
@@ -47,35 +48,67 @@ export class PerformanceDecorator implements vscode.Disposable
4748
if(!docInfo)
4849
return;
4950

50-
const method = docInfo.methods.firstOrDefault(m => m.symbol.id == codeObjectId);
51-
if(!method)
52-
return;
53-
54-
const lines = docInfo.lines.getAllByCurrentEnv().filter(l => method.range.contains(l.range.start));
55-
if(!lines)
56-
return;
51+
let decorators : vscode.DecorationOptions[] = [];
52+
53+
for (const method of docInfo.methods){
54+
55+
const insights = docInfo.insights.forMethod(method,this._workspaceState.environment)
56+
.filter(x=>x.name=="Performance Stats");
57+
58+
const percentileInfo = insights.map(x=>x as SpanDurationsInsight)
59+
.flatMap(x=>x.percentiles).filter(x=>x.currentDuration);
60+
61+
const totalDuration = percentileInfo.filter(x=>x.percentile==0.5).map(x=>x.currentDuration.raw)
62+
.reduce((acc, val)=>acc + val,0);
5763

58-
const textDecorationOptions: vscode.DecorationOptions[] = lines
59-
.map(lineInfo => {
60-
return <vscode.DecorationOptions>{
61-
hoverMessage: this.getTooltip(lineInfo),
64+
const lines = docInfo.lines.getAllByCurrentEnv().filter(l => method.range.contains(l.range.start));
65+
for (const lineInfo of lines ){
66+
decorators.push({
67+
hoverMessage: "",
6268
range: new vscode.Range(lineInfo.range.end, lineInfo.range.end),
6369
renderOptions: {
6470
after:{
65-
contentText: [...new Set( lineInfo.exceptions.map(e => e.type))].join('\xB7')
71+
contentText: `Duration: ${totalDuration}`
6672
}
6773
}
68-
}
69-
});
70-
const iconDecorationOptions = lines
71-
.map(lineInfo => {
72-
return <vscode.DecorationOptions>{
73-
range: new vscode.Range(lineInfo.range.end, lineInfo.range.end),
74-
}
75-
});
74+
75+
})
76+
}
77+
78+
79+
80+
// hoverMessage: this.getTooltip(lineInfo),
81+
// range: new vscode.Range(lineInfo.range.end, lineInfo.range.end),
82+
// renderOptions: {
83+
// after:{
84+
// contentText: [...new Set( lineInfo.exceptions.map(e => e.type))].join('\xB7')
85+
// }
86+
// }
87+
// }
88+
89+
}
90+
91+
// const textDecorationOptions: vscode.DecorationOptions[] = lines
92+
// .map(lineInfo => {
93+
// return <vscode.DecorationOptions>{
94+
// hoverMessage: this.getTooltip(lineInfo),
95+
// range: new vscode.Range(lineInfo.range.end, lineInfo.range.end),
96+
// renderOptions: {
97+
// after:{
98+
// contentText: [...new Set( lineInfo.exceptions.map(e => e.type))].join('\xB7')
99+
// }
100+
// }
101+
// }
102+
// });
103+
// const iconDecorationOptions = lines
104+
// .map(lineInfo => {
105+
// return <vscode.DecorationOptions>{
106+
// range: new vscode.Range(lineInfo.range.end, lineInfo.range.end),
107+
// }
108+
// });
76109

77-
editor.setDecorations(this._iconDecorationType, iconDecorationOptions);
78-
editor.setDecorations(this._textDecorationType, textDecorationOptions);
110+
editor.setDecorations(this._iconDecorationType, decorators);
111+
//editor.setDecorations(this._textDecorationType, textDecorationOptions);
79112
}
80113

81114
private async onHide()

0 commit comments

Comments
 (0)