From 93ca72eb3eaeffcbdd30c1704426eaf5492e2606 Mon Sep 17 00:00:00 2001 From: Yash Ladha Date: Tue, 16 Mar 2021 22:15:02 +0530 Subject: [PATCH] perf: add toJSON to performance class Added toJSON method to the InternalPerformance class as per the convention followed in other performance classes and per the spec: https://www.w3.org/TR/hr-time/#tojson-method Fixes: #37623 --- doc/api/perf_hooks.md | 9 +++++++++ lib/perf_hooks.js | 8 ++++++++ test/parallel/test-tojson-perf_hooks.js | 14 ++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 test/parallel/test-tojson-perf_hooks.js diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index 4822ca331ee9ce..295267f195836f 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -43,6 +43,14 @@ added: v8.5.0 An object that can be used to collect performance metrics from the current Node.js instance. It is similar to [`window.performance`][] in browsers. +### `performance.toJSON()` + + +An object which is JSON representation of the `performance` object. It +is similar to [`window.performance.toJSON`][] in browsers. + ### `performance.clearMarks([name])`