Permalink
Browse files

[bench] Add a small parser performance stress test

  • Loading branch information...
1 parent e00627a commit d2ca96d04f93fb888139b06d6f236d5f13502840 @3rd-Eden committed Jan 30, 2013
Showing with 22 additions and 0 deletions.
  1. BIN benchmark/responses
  2. +22 −0 benchmark/stress.js
View
Binary file not shown.
View
@@ -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.