]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | /* |
2 | * Performance.now() polyfill | |
3 | * | |
4 | * http://www.w3.org/TR/hr-time/#sec-high-resolution-time | |
5 | * | |
6 | * Dummy implementation which uses the Date built-in and has no higher | |
7 | * resolution. If/when Duktape has a built-in high resolution timer | |
8 | * interface, reimplement this. | |
9 | */ | |
10 | ||
11 | var _perfNowZeroTime = Date.now(); | |
12 | ||
13 | if (typeof Performance === 'undefined') { | |
14 | Object.defineProperty(this, 'Performance', { | |
15 | value: {}, | |
16 | writable: true, enumerable: false, configurable: true | |
17 | }); | |
18 | } | |
19 | if (typeof Performance.now === 'undefined') { | |
20 | Object.defineProperty(Performance, 'now', { | |
21 | value: function () { | |
22 | return Date.now() - _perfNowZeroTime; | |
23 | }, writable: true, enumerable: false, configurable: true | |
24 | }); | |
25 | } |