summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/dts/lib.deno.shared_globals.d.ts4
-rw-r--r--cli/tests/unit/performance_test.ts9
2 files changed, 13 insertions, 0 deletions
diff --git a/cli/dts/lib.deno.shared_globals.d.ts b/cli/dts/lib.deno.shared_globals.d.ts
index b96c56dba..d430c16b0 100644
--- a/cli/dts/lib.deno.shared_globals.d.ts
+++ b/cli/dts/lib.deno.shared_globals.d.ts
@@ -450,6 +450,7 @@ declare class Worker extends EventTarget {
declare type PerformanceEntryList = PerformanceEntry[];
declare class Performance {
+ /** Returns a timestamp representing the start of the performance measurement. */
readonly timeOrigin: number;
constructor();
@@ -490,6 +491,9 @@ declare class Performance {
* ```
*/
now(): number;
+
+ /** Returns a JSON representation of the performance object. */
+ toJSON(): any;
}
declare var performance: Performance;
diff --git a/cli/tests/unit/performance_test.ts b/cli/tests/unit/performance_test.ts
index 252a31fc4..917546e2c 100644
--- a/cli/tests/unit/performance_test.ts
+++ b/cli/tests/unit/performance_test.ts
@@ -27,6 +27,15 @@ Deno.test(function timeOrigin() {
assert(Date.now() >= origin);
});
+Deno.test(function performanceToJSON() {
+ const json = performance.toJSON();
+
+ assert("timeOrigin" in json);
+ assert(json.timeOrigin === performance.timeOrigin);
+ // check there are no other keys
+ assertEquals(Object.keys(json).length, 1);
+});
+
Deno.test(function performanceMark() {
const mark = performance.mark("test");
assert(mark instanceof PerformanceMark);