Permalink
Browse files

Fix to use runMain()

  • Loading branch information...
1 parent 910d115 commit 40222167b8ba3615afaa7bc9197e52b596e244f2 @isaacs committed Sep 29, 2010
Showing with 36 additions and 1 deletion.
  1. +34 −0 examples/date-cache.js
  2. +2 −1 examples/push-vs-length.js
View
@@ -0,0 +1,34 @@
+#!/usr/bin/env node
+
+var dateCache = null
+function utcCached () {
+ if (dateCache) return dateCache;
+ dateCache = new Date().toUTCString();
+ setTimeout(function () {
+ dateCache = null
+ }, 1000)
+ return dateCache;
+}
+
+function utcCached2 () {
+ if (!date_cache) {
+ update_date();
+ }
+ return date_cache;
+}
+function update_date() {
+ date_cache = new Date().toUTCString();
+ setTimeout(update_date, 1000);
+}
+
+function utc () {
+ return new Date().toUTCString()
+}
+
+exports.time = 10000;
+exports.compare =
+ { "cached" : utcCached
+ , "uncached" : utc
+ }
+
+require("bench").runMain()
@@ -1,4 +1,4 @@
-#!/usr/bin/env node-bench
+#!/usr/bin/env node
var p = [], l = [], c = [], f = [],
pi = 0, li = 0, ci = 0, fi = 0,
@@ -41,6 +41,7 @@ exports.compare = {
}
}
+require("bench").runMain()
/**
benchmarking /Users/isaacs/Documents/src/js/node-bench/examples/push-vs-length

0 comments on commit 4022216

Please sign in to comment.