omg

@patuach/oh-my-gauge

Gauge and Benchmark - time Javascript operations

Showing:

Popularity

Downloads/wk

0

Maintenance

No Maintenance Data Available

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Oh My Gauge!

Gauge - time Javascript operations

npm package Codeship Status

pull requests issues

Install

npm i @patuach/oh-my-gauge
const {Gauge, Benchmark} = require('@patuach/oh-my-gauge');

Usage

Gauge

const Gauge = require('@patuach/oh-my-gauge').Gauge;
const gauge = new Gauge((res, name) => console.log(`${name} took ${res}ms`));
//                        ^     ^         ^
//              Milliseconds  String   report-method

const myObj = {
    name: 'My Obj',
    sayName: function() {
        return this.name;
    }
};

myObj.sayName = gauge(myObj.sayName, 'sayName method');

Benchmark

const Benchmark = require('@patuach/oh-my-gauge').Benchmark;
const benchmark = new Benchmark();

benchmark(
  100000,
  [() => {/* Do thing one   */}, 'Thing 1 description'],
  [() => {/* Do thing two   */}, 'Thing 2 description'],
  [() => {/* Do thing three */}, 'Thing 3 description']
);

Or use a map

const Benchmark = require('@patuach/oh-my-gauge/lib/benchmark'); // Require to the module directly
const benchmark = new Benchmark(
    console.warn, // override the default console.log callback
    (ms, name) => `Method: ${name}, Time: ${ms}` // override default formatter
);

const things = new Map();
things.set(() => {/* Do thing one   */}, 'Thing 1 description');
things.set(() => {/* Do thing two   */}, 'Thing 2 description');
things.set(() => {/* Do thing three */}, 'Thing 3 description');

benchmark(1e5, things);

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial