-
Notifications
You must be signed in to change notification settings - Fork 1
/
ejs-tj.js
47 lines (41 loc) · 1.08 KB
/
ejs-tj.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
var ejs = require('ejs-tj')
var fs = require('fs')
var ejsCompiled = []
var locals = [
{
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' }
]
}
, {}
]
// Jade doesn't use with () {} so make it fair
// Jade also doesn't support dynamic inclusion
var ejsOpts = { _with: false }
var ejsOpts = { compileDebug: false, _with: false }
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('ejs/' + f + '.ejs', 'utf8')
ejsCompiled.push(ejs.compile(src, ejsOpts))
}
for (var i = 0; i < files.length; i ++) {
var f = files[i]
var local = locals[i]
var fn = ejsCompiled[i]
console.time(f)
for (var j = 0; j < 1000000; j ++) fn(local)
console.timeEnd(f)
}