Sign In

perf-fn

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perf-fn

Measure async and sync function execution time using the Performance API

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
152
4966.67%
Maintainers
1
Weekly downloads
 
Created
Source

perf-fn

Measure async and sync function execution time using the Performance API

Install

npm install perf-fn

Usage

import perfFn, {perfFnSync} from 'perf-fn';

const {result, duration} = await perfFn(async () => {
	const response = await fetch('https://example.com');
	return response.status;
});

console.log(`Took ${duration}ms`);

const {result: data, duration: syncTime} = perfFnSync(() => JSON.parse('{"key": "value"}'));

API

perfFn(function_)

Returns a Promise<{result, duration}> where duration is in milliseconds.

function_

Type: () => T | Promise<T>

The async or sync function to measure.

perfFnSync(function_)

Returns {result, duration} where duration is in milliseconds.

function_

Type: () => T

The sync function to measure.

  • abort-timer - Create an AbortSignal that aborts after a timeout

License

MIT

Keywords

performance

FAQs

Package last updated on 16 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts