Skip to content

Commit 10408a2

Browse files
authored
Merge pull request #64 from DeepCodeAI/analysis_timing
Added analysis timing node to results.
2 parents a42187f + 1916a76 commit 10408a2

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/deepcode/lib/modules/BundlesModule.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import { analyzeFolders, extendAnalysis } from '@deepcode/tsc';
1111
abstract class BundlesModule extends LoginModule implements BundlesModuleInterface {
1212
runningAnalysis = false;
1313

14+
private lastAnalysisStartingTimestamp = Date.now();
15+
lastAnalysisDuration = 0;
16+
lastAnalysisTimestamp = Date.now();
17+
1418
files: string[] = [];
1519

1620
updateStatus(status: string, progress: string) {
@@ -57,6 +61,7 @@ abstract class BundlesModule extends LoginModule implements BundlesModuleInterfa
5761
return;
5862
}
5963
this.runningAnalysis = true;
64+
this.lastAnalysisStartingTimestamp = Date.now();
6065

6166
let result;
6267
if (this.changedFiles.size && this.remoteBundle) {
@@ -84,6 +89,8 @@ abstract class BundlesModule extends LoginModule implements BundlesModuleInterfa
8489
});
8590
} finally {
8691
this.runningAnalysis = false;
92+
this.lastAnalysisTimestamp = Date.now();
93+
this.lastAnalysisDuration = this.lastAnalysisTimestamp - this.lastAnalysisStartingTimestamp;
8794
}
8895
}
8996
}

src/deepcode/view/IssueProvider.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,16 @@ export class IssueProvider extends NodeProvider {
115115
}),
116116
);
117117
} else {
118-
review.unshift(
119-
new Node({
120-
text: `DeepCode found ${!nIssues ? 'no issue! ✅' : `${nIssues} issue${nIssues === 1 ? '' : 's'}`}`,
121-
}),
122-
);
118+
review.unshift(new Node({
119+
text: `DeepCode found ${!nIssues ? 'no issue! ✅' : `${nIssues} issue${nIssues === 1 ? '' : 's'}`}`,
120+
}));
121+
const sDuration = Math.round((this.extension.lastAnalysisDuration / 1000 + Number.EPSILON) * 100) / 100;
122+
const ts = new Date(this.extension.lastAnalysisTimestamp);
123+
const time = ts.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
124+
const day = ts.toLocaleDateString([], { year: "2-digit", month: "2-digit", day: "2-digit" });
125+
review.unshift(new Node({
126+
text: `Analysis took ${sDuration}s, finished at ${time}, ${day}`,
127+
}));
123128
}
124129
return review;
125130
}

src/interfaces/DeepCodeInterfaces.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export interface LoginModuleInterface {
5656

5757
export interface BundlesModuleInterface {
5858
readonly runningAnalysis: boolean;
59+
readonly lastAnalysisDuration: number;
60+
readonly lastAnalysisTimestamp: number;
5961
startAnalysis(): Promise<void>;
6062
}
6163

0 commit comments

Comments
 (0)