Skip to content

Commit

Permalink
Implementing Simple Timer (#19786)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
adityashahms authored Apr 19, 2024
1 parent 83f81a0 commit 0346829
Show file tree
Hide file tree
Showing 28 changed files with 1,329 additions and 665 deletions.
32 changes: 32 additions & 0 deletions Tasks/AzureTestPlanV0/SimpleTimer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { ciDictionary } from "./ciEventLogger";
import * as tl from 'azure-pipelines-task-lib/task';
let perf = require('performance-now');

export class SimpleTimer {
private startTime: number;
private endTime: number;
private featureName: string;

constructor(featureName: string) {
this.startTime = 0;
this.endTime = 0;
this.featureName = featureName;
}

start() {
this.startTime = perf();
}

stop(ciData:ciDictionary) {
this.endTime = perf();
tl.debug(`Execution Time for ${this.featureName} was ${this.getElapsedTime()} in milli-seconds`);
ciData[`Execution Time for ${this.featureName} in milli-seconds`] = this.getElapsedTime();
}

getElapsedTime(): number {
if (this.startTime === 0 || this.endTime === 0) {
throw new Error("Timer has not been started or stopped.");
}
return this.endTime - this.startTime;
}
}
Loading

0 comments on commit 0346829

Please sign in to comment.