Skip to content

Commit

Permalink
[bench] Add a small parser performance stress test
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Jan 30, 2013
1 parent e00627a commit d2ca96d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Binary file added benchmark/responses
Binary file not shown.
22 changes: 22 additions & 0 deletions benchmark/stress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

var parser = new (require('../').Parser)()
, control = require('fs').readFileSync('./responses', 'utf8');

//
// Stress test parameters
//
var NR_OF_RUNS = 100;

var start = Date.now();

for (var i = 0; i < NR_OF_RUNS; i++) {
parser.write(control);
}

var end = Date.now()
, timespend = end - start
, bytes = Buffer.byteLength(control) * NR_OF_RUNS;

console.log(timespend + ' ms');
console.log(bytes/timespend + ' bytes/ms');

0 comments on commit d2ca96d

Please sign in to comment.