Skip to content

Commit

Permalink
Proper oom calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 29, 2010
1 parent 4022216 commit d14aa70
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/bench.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ function run (fn, time, countPerLap, cb) {
lap(); lap();
}; };
runner(); runner();

return p;
}; };


function compare (set, compareCount, time, countPerLap, cb) { function compare (set, compareCount, time, countPerLap, cb) {
Expand Down Expand Up @@ -168,12 +166,14 @@ function pct (num1, num2) {
function times (num1, num2) { function times (num1, num2) {
return Math.round((Math.max(num1, num2)/Math.min(num1, num2)) * 100) / 100; return Math.round((Math.max(num1, num2)/Math.min(num1, num2)) * 100) / 100;
} }
function logX (n, x) {
return Math.log(n)/Math.log(x)
}
function oom (num1, num2) { function oom (num1, num2) {
var ratio = Math.max(num1, num2)/Math.min(num1, num2), var l1 = logX(num1, 10)
oom = 0; , l2 = logX(num2, 10)
// poor man's logarithm , diff = Math.abs( l1 - l2 )
while ( (ratio/=10) > 0.9 ) oom++; return Math.round(diff * 100) / 100
return oom;
} }
function avg (nums) { function avg (nums) {
var sum = 0; var sum = 0;
Expand Down

0 comments on commit d14aa70

Please sign in to comment.