connect-composer-stats
Statistics for connect-composer middlewares
Enable runtime measurements for composed middlewares using connect-composer to track down latency problems within middlewares.
Inject either globally or locally into your composed middlewares and dump results into a CVS file.
Table of Contents
Description
Set globally for all composed middlewares
var composestats = var compose = // get new stats objectvar stats = // globally inject stats use:composeoptions = stats: statsfrom // a middleware functionvar { }// composing the single middlewaresvar mws = var req = {} res = {}
Set locally for a single composed middlewares
var composestats = var compose = // get new stats objectvar stats = // a middleware functionvar { }// composing the single middlewaresvar mws = // locally inject stats use:mwsoptions = stats: statsfrom var req = {} res = {}
Wrap arround a single middleware function
var composestats = var compose = // get new stats objectvar stats = // a middleware functionvar { }// wrapping the stats middlewarevar wrap = stats var req = {} res = {}
Methods
stats()
create statistics for middleware(s)
Returns: Object
, object with functions
from(fn)
take statistics from middleware function fn
Parameters
fn: function
, middleware function from which to generate the statistics
Returns: function
, wrapped middleware function
dump(options)
Dump the collected statistics into a csv file or to stdout
Parameters
options: Object
, options
- ns: false, // {Boolean} if
false
output is in milliseconds; iftrue
then nanoseconds - dir: process.cwd(), // {String} dir where stats files are written; default current working dir
- csv: true, // {Boolean} of
true
output csv to filesystem; defaulttrue
- sortkey: 'total' // {String} key to reverse sort (total, average, max, min)
Returns: String
, filename of csv file
data
The data object where the statistics for each function are stored
Example
'./example.js:16:19:mwG': name: './example.js:16:19:mwG' // file, line, column and name of function called count: 3 // number of function calls total: 6389 // time in nanoseconds min: 826 max: 2923 './example.js:14:18:mw': name: './example.js:14:18:mw' count: 2 total: 1662 min: 742 max: 920
Contribution and License Agreement
If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work or correctly attributed with the source of its origin and licence.
License
Copyright (c) 2015 commenthol (MIT License)
See LICENSE for more info.