1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-23 23:49:46 -05:00
denoland-deno/cli/js/web/performance.ts

17 lines
480 B
TypeScript
Raw Normal View History

2020-01-02 15:13:47 -05:00
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { now as opNow } from "../ops/timers.ts";
2019-02-02 09:27:42 +03:00
export class Performance {
/** Returns a current time from Deno's start in milliseconds.
*
* Use the flag --allow-hrtime return a precise value.
2019-02-02 09:27:42 +03:00
*
* const t = performance.now();
* console.log(`${t} ms since start!`);
*/
now(): number {
const res = opNow();
2019-08-26 14:50:21 +02:00
return res.seconds * 1e3 + res.subsecNanos / 1e6;
2019-02-02 09:27:42 +03:00
}
}