Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chronolite

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chronolite

chronolite is a microlibrary for timing, comparing and benchmarking JavaScript functions. It supports both synchronous and asynchronous functions. Common use cases include performance benchmarking for a function, and benchmarking multiple functions agains

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Weekly downloads
 
Created
Source

chronolite 🕰️

chronolite is a microlibrary for timing, comparing and benchmarking JavaScript functions. It supports both synchronous and asynchronous functions. Common use cases include performance benchmarking for a function, and benchmarking multiple functions against each other.

Install

For npm:

npm install chronolite

For yarn:

yarn add chronolite

Usage

chronolite has 4 core methods:

  • time - Return the running time of a synchronous function
  • timeAsync - Return the running time of a async function (function must return a promise)
  • compare - Find the fastest function out of an array of functions
  • compareAsync - Find the fastest function out of an array of async functions

Methods take objects or arrays of objects of the following schema:

    {
        id: "someFunction", // - string (optional) 
        binding: null // object (optional) - The object to bind the function to (defaults to null)
        fn: someFunc, // function 
        fnArgs: [1, 2, 3], // array - The array of arguments
    }

Here is an example of using the time method:


    const timer = new chronolite();

    const fn = (input) => { 

        // Synthetic wait
        const ms = input * (Math.random() * 1);
        const start = Date.now();
        let now = start;
        while (now - start < ms) {
            now = Date.now();
        }

        return "finished";

    };

    const arg = [10];
    const iterations = 15;

    const time = timer.time({
        fn: first, 
        fnArgs: arg,
    }, iterations);

    console.log("Average time: ", time.averageTime);

License

MIT

Keywords

FAQs

Package last updated on 22 Dec 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc