Browse files

Make the DURATION for the set/filter configurable

This makes it easier to test if the numbers hold up when they get
bigger.
  • Loading branch information...
1 parent e8fcc75 commit 18f186bd71e4c437708cd1e1d4078684ded501c8 @felixge felixge committed Jan 8, 2010
Showing with 7 additions and 2 deletions.
  1. +3 −1 benchmark/filter.js
  2. +4 −1 benchmark/set.js
View
4 benchmark/filter.js
@@ -1,5 +1,7 @@
process.mixin(require('sys'));
var
+ DURATION = 1000,
+
Dirty = require('../lib/dirty').Dirty,
posts = new Dirty('posts')
start = +new Date(),
@@ -9,7 +11,7 @@ while (true) {
posts.set(i, {str: 'This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256'});
i++;
- if (i % 1000 && ((+new Date() - start) > 1000)) {
+ if (i % 1000 && ((+new Date() - start) > DURATION)) {
break;
}
}
View
5 benchmark/set.js
@@ -1,5 +1,7 @@
process.mixin(require('sys'));
var
+ DURATION = 1000,
+
Dirty = require('../lib/dirty').Dirty,
posts = new Dirty('posts')
start = +new Date(),
@@ -9,7 +11,8 @@ while (true) {
posts.set(i, {str: 'This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256 byte string. This is a 256'});
i++;
- if (i % 1000 && ((+new Date() - start) > 1000)) {
+ // Only run new Date() every 1000 records
+ if (i % 1000 && ((+new Date() - start) > DURATION)) {
break;
}
}

0 comments on commit 18f186b

Please sign in to comment.