Skip to content

Commit 0346829

Browse files
authored
Implementing Simple Timer (#19786)
* Implementing Simple Timer * Bumping Task Version * Updating Manual Test Flow * Adding generated file * Adding missing generated file * Updating Simple Timer with Perfomance lib * Updating package-lock.json
1 parent 83f81a0 commit 0346829

28 files changed

+1329
-665
lines changed

Tasks/AzureTestPlanV0/SimpleTimer.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { ciDictionary } from "./ciEventLogger";
2+
import * as tl from 'azure-pipelines-task-lib/task';
3+
let perf = require('performance-now');
4+
5+
export class SimpleTimer {
6+
private startTime: number;
7+
private endTime: number;
8+
private featureName: string;
9+
10+
constructor(featureName: string) {
11+
this.startTime = 0;
12+
this.endTime = 0;
13+
this.featureName = featureName;
14+
}
15+
16+
start() {
17+
this.startTime = perf();
18+
}
19+
20+
stop(ciData:ciDictionary) {
21+
this.endTime = perf();
22+
tl.debug(`Execution Time for ${this.featureName} was ${this.getElapsedTime()} in milli-seconds`);
23+
ciData[`Execution Time for ${this.featureName} in milli-seconds`] = this.getElapsedTime();
24+
}
25+
26+
getElapsedTime(): number {
27+
if (this.startTime === 0 || this.endTime === 0) {
28+
throw new Error("Timer has not been started or stopped.");
29+
}
30+
return this.endTime - this.startTime;
31+
}
32+
}

0 commit comments

Comments
 (0)