-
Notifications
You must be signed in to change notification settings - Fork 67
/
performance.js
92 lines (86 loc) · 1.83 KB
/
performance.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var pagination = require('./index.js');
var ItemPaginator = pagination.ItemPaginator;
var SearchPaginator = pagination.SearchPaginator;
function test() {
console.log('Running pagination performance');
/* pageLinks 5 by default; howto specify for Item Pattern */
var times = 1000000;
console.log(' * run new ItemPaginator.render ' + times);
var start = Date.now();
for( i = 0; i < times; i++) {
var item = new ItemPaginator({
prelink : '/',
pageLinks : 5,
current : 5,
totalResult : 98,
translationCache : true
});
item.render();
}
console.log(' * took: ' + (Date.now() - start) + ' ms');
console.log(' * run new SearchPaginator.render ' + times);
var start = Date.now();
for( i = 0; i < times; i++) {
var search = new SearchPaginator({
prelink : '/',
pageLinks : 5,
current : 5,
totalResult : 100
});
search.render();
}
console.log(' * took: ' + (Date.now() - start) + ' ms');
}
test();
/**
*
* v0.2.1
* string concat
* ---------------
* translationCache: true
*
* run new ItemPaginator.render 1000000
* took: 3482 ms
* run new SearchPaginator.render 1000000
* took: 2968 ms
*
*
* translationCache: false
*
* run new ItemPaginator.render 1000000
* took: 4313 ms
* run new SearchPaginator.render 1000000
* took: 3065 ms
*
* array.join
* --------------
* With cache of CURRENT_PAGE_REPORT
* translationCache : true
*
* took: 5095 ms
* run new SearchPaginator.render 1000000
* took: 5503 ms
*
* translationCache : false
*
* took: 6289 ms
* run new SearchPaginator.render 1000000
* took: 5266 ms
*
* v0.2.0
* run new ItemPaginator.render 1000000
* took: 6514 ms
* run new SearchPaginator.render 1000000
* took: 5297 ms
*
* cpus x4
* [ { model: 'MacBookAir4,2',
speed: 1800,
times:
{ user: 44032730,
nice: 0,
sys: 40634570,
idle: 367414930,
irq: 0 } },
... } ]
*/