FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

mapbox/cumulative-timer: A simple cumulative timer for benchmarking JavaScript applications. · GitHub

This repository was archived by the owner on Jun 18, 2026. It is now read-only.
/ cumulative-timer Public archive

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

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.stop('foo');
timer.start('bar'); /* ... */ timer.stop('bar');
timer.start('foo'); /* ... */ timer.stop('foo');

timer.stop('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.

About

A simple cumulative timer for benchmarking JavaScript applications.

Resources

Code of conduct

Contributing

Security policy

Stars

33 stars

Watchers

108 watching

Forks

Releases

Packages

Used by

Contributors

Languages


Back | FazBrowse Home | New Git URL