From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/nanotiming/example.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 node_modules/nanotiming/example.js (limited to 'node_modules/nanotiming/example.js') diff --git a/node_modules/nanotiming/example.js b/node_modules/nanotiming/example.js new file mode 100644 index 00000000..35b034ca --- /dev/null +++ b/node_modules/nanotiming/example.js @@ -0,0 +1,21 @@ +var nanotiming = require('./') + +try { + var hooks = require('perf_hooks') + var nanot = nanotiming('my-loop') // Start profiling +} catch (e) { + console.log('perf_hooks not available, exiting') + process.exit(1) +} +var performance = hooks.performance + +var i = 10 +while (--i) console.log(i) + +// Stop profiling +nanot() + +var timings = performance.getEntries() +var timing = timings[timings.length - 1] +console.log(timing.name, timing.duration) // log the last entry +performance.clearMeasures(timing.name) // be a good citizen and free after use -- cgit v1.2.3