forked from flatiron/plates
/
perf-test.js
62 lines (44 loc) · 1.16 KB
/
perf-test.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
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite();
var Mustache = require('mustache');
var Plates = require('../lib/plates');
suite
.add('mustache', function() {
var view = { "foo": "Hello, World" };
var template = '<div id="foo">{{foo}}</div><div class="foo">';
Mustache.to_html(template, view);
})
.add('plates', function() {
var view = { "foo": "Hello, World" };
var template = '<div id="foo"></div><div class="foo">';
Plates.bind(template, view);
})
.on('cycle', function(event, bench) {
console.log(String(bench));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
})
.add('mustache iterations', function() {
var view = {
"stooges": [
"Moe",
"Larry",
"Curly"
]
};
var template = '{{#stooges}}<b>{{name}}</b>{{/stooges}}';
Mustache.to_html(template, view);
})
.add('plates iterations', function() {
var view = {
"stooges": [
"Moe",
"Larry",
"Curly"
]
};
var template = '<b class="stooges">Name</b>';
Plates.bind(template, view);
})
.run(true);