-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtinyq.test.js
More file actions
37 lines (26 loc) · 900 Bytes
/
Copy pathtinyq.test.js
File metadata and controls
37 lines (26 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
define(function () {
function do_test(tag, loop, func1, func2, show) {
var x, y;
_time('time001');
_each(loop, function () { x = func1(); })
var t1 = _time('time001', false);
_time('time002');
_each(loop, function () { y = func2(); })
var t2 = _time('time002', false);
var color = t1 < t2 ? '[+]' : ':-:';
var xl = x;
var yl = y;
if (x && x.length != undefined) xl = x.length;
if (x && x.count != undefined) xl = x.count;
if (y && y.length != undefined) yl = y.length;
_log(color, xl === yl, tag, parse_time(t1), ':', parse_time(t2), '[' + xl + '/' + yl + ']');
if (show) {
_log(x);
_log(y);
}
}
function parse_time(t){
return parseFloat(t.toFixed(3));
}
return do_test;
})