time-stats
Node preload to replace console.time calls with better ones.
Last updated 5 years ago by bahmutov .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install time-stats 
SYNC missed versions from official npm registry.

time-stats

Node preload to replace console.time calls with better ones.

NPM

Build status semantic-release js-standard-style

If you have Node code that measures individual actions using console.time and console.timeEnd calls, you might want to know actual stats, like the median of the calls, min, max, mean. But you don't want to change your code to do this. Just preload time-stats and you will get this information.

function timeDelay (ms) {
  const label = 'delay'
  console.time(label)
  return delay(100).then(() => {
    console.timeEnd(label)
  })
}
// calling delay 5 times

before

node test/index.js
delay: 107.262ms
delay: 105.148ms
delay: 104.336ms
delay: 104.093ms
delay: 105.262ms

after

npm i time-stats
node -r time-stats test/index.js
delay: 107.673ms, min 107.673ms max 107.673ms median 107.673ms mean 107.673ms n=1
delay: 103.482ms, min 103.482ms max 107.673ms median 107.673ms mean 105.578ms n=2
delay: 102.874ms, min 102.874ms max 107.673ms median 103.482ms mean 104.677ms n=3
delay: 101.869ms, min 101.869ms max 107.673ms median 103.482ms mean 103.975ms n=4
delay: 103.503ms, min 101.869ms max 107.673ms median 103.482ms mean 103.88ms n=5

Small print

Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2016

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2016 Gleb Bahmutov <gleb.bahmutov@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Current Tags

  • 1.1.0                                ...           latest (5 years ago)

3 Versions

  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (13)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |