# 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

Latest version **0.0.5** (published 2018-12-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install chronolite
pnpm add chronolite
yarn add chronolite
bun add chronolite
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2018-12-22 |
| First published | 2018-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 132.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jamesmilneruk |
| Keywords | performance, benchmark, timing, timer, perf, compare, functions |

## Links

- npm: https://www.npmjs.com/package/chronolite
- Repository: https://github.com/JamesMilnerUK/chronolite
- Homepage: https://github.com/JamesMilnerUK/chronolite#readme
- Issues: https://github.com/JamesMilnerUK/chronolite/issues
- npm.io page: https://npm.io/package/chronolite

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2018-12-22
- 0.0.4 — 2018-03-24
- 0.0.3 — 2018-03-24
- 0.0.2 — 2018-03-24
- 0.0.1 — 2018-03-11

## README

# 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:

```javascript
    {
        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:

```javascript 

    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

---
_Source: https://npm.io/package/chronolite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
