klocka

1.1.0 • Public • Published

npm version Build Status

klocka

Timing things in node.js

install

$ npm install klocka

wat?

  • klocka logs time elapsed between A and B in ms. A is wherever you decide to put it and B is when response.end (or equivalent) is called.
  • Works with express and vanilla node
  • No dependencies
  • Uses high resolution time APIs time and timeEnd that requires Node v0.1.104+

Usage w Express

// require
var klocka = require('klocka');
 
// to capture all and everything
app.use(klocka); // logs: klocka <method> <path> <duration in ms>
 
// to capture a specific route
app.use('/items', klocka);
 
// note: Express adds two middlewares by default that will not be included in the duration. Read more [here](http://www.nickstefan.net/blog/view/express-under-the-hood)

Test

$ npm test

TODOs

  • add colours to output?
  • use table to align output?
  • add an average per route?
  • add custom start/stop?
  • use server event 'request' to start? Would require passing the server instance and maybe the response object as args. Not solved yet

Licence

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    2
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i klocka

Weekly Downloads

2

Version

1.1.0

License

MIT

Last publish

Collaborators

  • karlpokus