equal
deleted
inserted
replaced
8 * Use 'ctx' to initialise test and to pass state between calls. */ |
8 * Use 'ctx' to initialise test and to pass state between calls. */ |
9 function perf(msg, fn, n, ctx) { |
9 function perf(msg, fn, n, ctx) { |
10 if (typeof n !== "number" || n < 1) |
10 if (typeof n !== "number" || n < 1) |
11 n = 1; |
11 n = 1; |
12 var tsFrom = new Date().getTime(); |
12 var tsFrom = new Date().getTime(); |
13 for (i = 0; i < n; i++) |
13 for (var i = 0; i < n; i++) |
14 fn.call(ctx); |
14 fn.call(ctx); |
15 var tsTo = new Date().getTime(); |
15 var tsTo = new Date().getTime(); |
16 console.log(msg + ": %f ms, %d u/s", tsTo-tsFrom, i/(tsTo - tsFrom)*1000); |
16 console.log(msg + ": %f ms, %d u/s", tsTo-tsFrom, i/(tsTo - tsFrom)*1000); |
17 } |
17 } |
18 |
18 |