Skip to content

Instantly share code, notes, and snippets.

@fengmk2
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save fengmk2/9b6a76685d50e8a22b6b to your computer and use it in GitHub Desktop.

Select an option

Save fengmk2/9b6a76685d50e8a22b6b to your computer and use it in GitHub Desktop.
http-errors benchmark
var createError = require('http-errors');
var start = Date.now();
var count = 100000;
for (var i = 0; i < count; i++) {
createError(401, 'Please login to view this page.', {
stat: 'foo error',
errors: [
{
foo: 'bar',
},
{
foo2: 'bar2',
}
]
});
}
var use = Date.now() - start;
console.log('http-errors: %d times use %d ms, qps: %d', count, use, count / use * 1000);
// $ node --harmony bench.js
// http-errors: 100000 times use 2169 ms, qps: 46104.19548178884
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment