Skip to content

trapcodeio/benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Personal Benchmark Kit

This packages only provides semantic helper functions for the original Benchmark

Installation

npm i @trapcode/benchmark
# OR
yarn add @trapcode/benchmark

Functions

List of functions available in this package.

benchmarkFunctions

This function benchmarks an array/record of functions given to it.

Syntax

import {benchmarkFunctions} from "@trapcode/benchmark"

benchmarkFunctions(FunctionsArray, options)

benchmarkFunctions(FunctionsObject, options)

benchmarkFunctions(Name, FunctionsArray | FunctionsObject, options)

Example

import {benchmarkFunctions} from "@trapcode/benchmark"

function One() {
    return 1 + 1;
}

function Two() {
    // run one 100 times
    let i = 100;
    while (--i) One();
}

function Three() {
    // run two 100 times
    let i = 100;
    while (--i) Two();
}

// An array of functions
benchmarkFunctions([One, Two, Three]).run();

// Or an object of functions.
benchmarkFunctions({ One, Two, Three }).run();

Result

One x 894,565,407 ops/sec ±1.12% (84 runs sampled)
Two x 16,723,630 ops/sec ±0.89% (90 runs sampled)
Three x 190,309 ops/sec ±0.46% (95 runs sampled)
Fastest is [One]

Releases

No releases published

Packages

No packages published