forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.ts
More file actions
52 lines (41 loc) · 1.37 KB
/
Copy pathtimer.ts
File metadata and controls
52 lines (41 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
///<reference path='references.ts' />
var global: any = <any>Function("return this").call(null);
module TypeScript {
module Clock {
export var now: () => number;
export var resolution: number;
declare module WScript {
export function InitializeProjection(): void;
}
declare module TestUtilities {
export function QueryPerformanceCounter(): number;
export function QueryPerformanceFrequency(): number;
}
if (typeof WScript !== "undefined" && typeof global['WScript'].InitializeProjection !== "undefined") {
// Running in JSHost.
global['WScript'].InitializeProjection();
now = function () {
return TestUtilities.QueryPerformanceCounter();
};
resolution = TestUtilities.QueryPerformanceFrequency();
}
else {
now = function () {
return Date.now();
};
resolution = 1000;
}
}
export class Timer {
public startTime: number;
public time = 0;
public start() {
this.time = 0;
this.startTime = Clock.now();
}
public end() {
// Set time to MS.
this.time = (Clock.now() - this.startTime);
}
}
}