How to use perf_hooks - 10 common examples

To help you get started, we’ve selected a few perf_hooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Wulf / nodehun / test / performance / performance.ts View on Github external
const suggestSync3Test = (word: string): number => {
  let start = performance.now()
  nodehun3.suggestSync(word)
  let end = performance.now()
  return end - start
}
github elbywan / wretch / test / node / wretch.spec.ts View on Github external
function (url, opts) {
        performance.mark(url + " - begin")
        const { fetch } = abortableFetch(nodeFetch) as any
        return fetch(url, opts).then(_ => {
            performance.mark(url + " - end")
            const measure = () => performance.measure(_.url, url + " - begin", url + " - end")
            performance.clearMarks(url + " - begin")
            if(timeout)
                setTimeout(measure, timeout)
            else
                measure()
            return _
        })
    }
github graalvm / graaljs / test / parallel / test-trace-events-api.js View on Github external
setTimeout(() => {
    performance.mark('B');
    performance.measure('A to B', 'A', 'B');
  }, 1);
github graalvm / graaljs / test / parallel / test-trace-events-perf.js View on Github external
setTimeout(() => {
    performance.mark('B');
    performance.measure('A to B', 'A', 'B');
  }, 1);
github node-webrtc / node-webrtc / test / latency.js View on Github external
remoteDataChannel.addEventListener('message', ({ data }) => {
    if (times.length < n) {
      const timestamp = Number.parseFloat(data);
      const time = performance.now() - timestamp;
      times.push(time);
    }
  });
github fuse-box / fuse-box / src / transform / _benchmark.ts View on Github external
function measure(name: string, fn: () => void) {
  const start = performance.now();
  fn();
  const time = performance.now() - start;
  if (!result[name]) {
    result[name] = [];
  }
  result[name].push(time);
  //console.log(`${name} in: ${time}ms`);
  return name;
}
github fuse-box / fuse-box / src / _experimental / typescript / _benchmark.ts View on Github external
function measure(name: string, fn: () => void) {
	const start = performance.now();
	fn();
	const time = performance.now() - start;
	if (!result[name]) {
		result[name] = [];
	}
	result[name].push(time);
	//console.log(`${name} in: ${time}ms`);
	return name;
}
github fuse-box / fuse-box / playground / bench.ts View on Github external
function measure(name: string, fn: () => void) {
  const start = performance.now();
  fn();
  const time = performance.now() - start;
  if (!result[name]) {
    result[name] = [];
  }
  result[name].push(time);
  //console.log(`${name} in: ${time}ms`);
  return name;
}
github fuse-box / fuse-box / src / analysis / _benchmark.ts View on Github external
function measure(name: string, fn: () => void) {
  const start = performance.now();
  fn();
  const time = performance.now() - start;
  if (!result[name]) {
    result[name] = [];
  }
  result[name].push(time);
  //console.log(`${name} in: ${time}ms`);
  return name;
}
github bcinarli / uxr / build / logger.js View on Github external
const perf = name => {
    if (measures.includes(name)) {
        performance.mark(`${name}_end`);
        performance.measure(`${name} start to ${name} end`, name, `${name}_end`);
        //let measure = performance.getEntriesByName(`${name} start to ${name} end`)[0];
        //log(`${name} Done in ${(measure.duration/1000).toFixed(2)}s.`);

        clearPerf(name);
    }

    else {
        performance.mark(name);
        const obs = new PerformanceObserver((list, observer) => {
            console.log(list.getEntries());
            observer.disconnect();
        });
        measures.push(name);
    }
};

perf_hooks

placeholder for Node core module

MIT
Latest version published 7 years ago

Package Health Score

50 / 100
Full package analysis

Similar packages