JSPM

cumulative-timer

1.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 2
    • Score
      100M100P100Q39797F
    • License ISC

    A simple cumulative timer for benchmarking JavaScript apps

    Package Exports

    • cumulative-timer

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cumulative-timer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    cumulative-timer

    A simple cumulative timer for benchmarking. Similar to console.time & console.timeEnd, but accumulates time for a particular id over many calls.

    Example

    var timer = require('cumulative-timer');
    
    timer.start('total');
    
    timer.start('foo'); /* ... */ timer.end('foo');
    timer.start('bar'); /* ... */ timer.end('bar');
    timer.start('foo'); /* ... */ timer.end('foo');
    
    timer.end('total');
    
    timer.log();

    Produces the following output:

     700ms 100.00% total
     204ms  29.14% foo
     496ms  70.86% bar

    Note that the total timer id has a special treatment — it's used for the percentage calculation on the log. If there's no such id, the output will be just milliseconds.

    For raw JSON of accumulated times, access timer.times.

    The timer is global — you can require it from different files, and the acummulated time stats will be shared.

    Should also work in browsers with Browserify.