func-timer
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

func-timer

Measure the execution time of a Node.js function. Supports both async functions and functions which take arguments.

Installation

npm install func-timer

Usage

import { ExecutionTimerResult, measureExecutionTime } from 'func-timer';

async function doStuff(arg1: number, arg2: string): number[]
{
    // code you want to measure
    return [1,2,3];
}

async function main()
{
    // Runs your func 10 times with the same inputs, averages the runtimes.
    const numIterations = 10;
    // This function logs information to console, but you can also access the results directly if you're using them in a mocha test for example.
    const result: ExecutionTimerResult = await measureExecutionTime(doStuff, [42, 'dummyArg2'], numIterations);
}

main();

License

MIT

/func-timer/

    Package Sidebar

    Install

    npm i func-timer

    Weekly Downloads

    0

    Version

    0.1.4

    License

    MIT

    Unpacked Size

    8.76 kB

    Total Files

    8

    Last publish

    Collaborators

    • mostlyarmless