Skip to content
Browse files

Add the "runMain"

  • Loading branch information...
1 parent 24271c4 commit f0697841c72f6bb4c6f8d1fac078fc5e38fa80c5 @isaacs committed
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/bench.js
View
17 lib/bench.js
@@ -6,6 +6,23 @@ exports.STEPS_PER_LAP = 1000;
exports.run = run;
exports.compare = compare;
exports.show = show;
+exports.runMain = runMain
+
+function runMain () {
+ var test = require.main.exports
+ if (test === require("./cli-wrapper")) return
+
+ console.log("benchmarking "+require.main.filename+"\nPlease be patient.")
+ if (test.stepsPerLap) exports.STEPS_PER_LAP = test.stepsPerLap
+
+ compare
+ ( test.compare
+ , test.compareCount || exports.COMPARE_COUNT
+ , test.time || exports.TIME
+ , test.countPerLap || exports.COUNT_PER_LAP
+ , function (er, data) { (test.done || exports.show)(data) }
+ )
+}
var events = require("events"),
sys = require("sys");

0 comments on commit f069784

Please sign in to comment.
Something went wrong with that request. Please try again.