Skip to content

Commit fc4a4e1

Browse files
committed
Added analysis timing node to results.
1 parent 053bb5d commit fc4a4e1

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/deepcode/lib/modules/BundlesModule.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ abstract class BundlesModule extends LoginModule
1616

1717
runningAnalysis = false;
1818

19+
private lastAnalysisStartingTimestamp: number;
20+
lastAnalysisDuration: number;
21+
lastAnalysisTimestamp: number;
22+
1923
files: string[] = [];
2024
serviceAI = http.getServiceAI();
2125

@@ -31,6 +35,9 @@ abstract class BundlesModule extends LoginModule
3135
this.onError = this.onError.bind(this);
3236

3337
this.serviceAI.on(BUNDLE_EVENTS.error, this.onError);
38+
this.lastAnalysisDuration = 0;
39+
this.lastAnalysisStartingTimestamp = _.now();
40+
this.lastAnalysisTimestamp = _.now();
3441
}
3542

3643
updateStatus(status: string, progress?: number) {
@@ -146,6 +153,8 @@ abstract class BundlesModule extends LoginModule
146153
private terminateAnalysis(): void {
147154
this.serviceAI.removeListeners();
148155
this.runningAnalysis = false;
156+
this.lastAnalysisTimestamp = _.now();
157+
this.lastAnalysisDuration = this.lastAnalysisTimestamp - this.lastAnalysisStartingTimestamp;
149158
}
150159

151160
public async performBundlesActions(path: string): Promise<void> {
@@ -291,6 +300,8 @@ abstract class BundlesModule extends LoginModule
291300
return;
292301
}
293302

303+
this.lastAnalysisStartingTimestamp = _.now();
304+
294305
this.createWorkspacesList(workspaceFolders);
295306

296307
if (this.workspacesPaths.length) {

src/deepcode/view/IssueProvider.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ export class IssueProvider extends NodeProvider {
129129
review.unshift(new Node({
130130
text: `DeepCode found ${!nIssues ? 'no issue! ✅' : `${nIssues} issue${nIssues === 1 ? '' : 's'}`}`,
131131
}));
132+
const sDuration = Math.round((this.extension.lastAnalysisDuration / 1000 + Number.EPSILON) * 100) / 100;
133+
const ts = new Date(this.extension.lastAnalysisTimestamp);
134+
const time = ts.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
135+
const day = ts.toLocaleDateString(undefined, { year: "2-digit", month: "2-digit", day: "2-digit" });
136+
review.unshift(new Node({
137+
text: `Analysis took ${sDuration}s, finished at ${time}, ${day}`,
138+
}));
132139
}
133140
return review;
134141
}

src/interfaces/DeepCodeInterfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ namespace DeepCode {
218218

219219
export interface BundlesModuleInterface {
220220
readonly runningAnalysis: boolean;
221+
readonly lastAnalysisDuration: number;
222+
readonly lastAnalysisTimestamp: number;
221223
startAnalysis(): Promise<void>;
222224
createFilesFilterList(): Promise<void>;
223225
createWorkspacesList(workspaces: WorkspaceFolder[]): void;

0 commit comments

Comments
 (0)