forked from TimothyGu/jade-ejs-bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjade.js
43 lines (37 loc) · 1.09 KB
/
jade.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
var jade = require('jade')
var fs = require('fs')
var jadeCompiled = []
var things = [
{ a: 'blah', b: 'halb' }
, { a: 'clah', b: 'halc' }
, { a: 'clah', b: 'halc' }
, { a: 'blah', b: 'halb' }
, { a: 'clah', b: 'halc' }
, { a: 'clah', b: 'halc' }
, { a: 'clah', b: 'halc' }
, { a: 'blah', b: 'halb' }
, { a: 'blah', b: 'halb' }
, { a: 'clah', b: 'halc' }
, { a: 'blah', b: 'halb' }
]
var locals = [{things:things}, {things:things}, {things:things}, {things:things}, {}]
var jadeOpts = { }
var jadeOpts = { compileDebug: false }
var jadeOpts = { compileDebug: false, self: true }
var files = fs.readdirSync('jade').map(function (f) {
return f.split('.')[0]
})
for (var i = 0; i < files.length; i ++) {
var f = files[i]
var src = fs.readFileSync('jade/' + f + '.jade', 'utf8')
jadeCompiled.push(jade.compile(src, jadeOpts))
}
for (var i = 0; i < files.length; i ++) {
var f = files[i]
var local = locals[i]
var fn = jadeCompiled[i]
for (var j = 0; j < 200000; j ++) fn(local)
console.time(f)
for (var j = 0; j < 2000000; j ++) fn(local)
console.timeEnd(f)
}