-
Notifications
You must be signed in to change notification settings - Fork 285
/
nodetest.js
36 lines (32 loc) · 840 Bytes
/
nodetest.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
var sys = require('sys');
var m = require("mustache");
var fs = require("fs");
var items = [{name:"red", current:true, url:"#Red", link:false},
{name:"green", current:false, url:"#Green", link:true},
{name:"blue", current:false, url:"#Blue", link:true}];
var view = {
header : "Colors",
item : items,
list:function() {
return items.length != 0;
},
empty:function() {
return items.length == 0;
}
};
fs.readFile("src/test/resources/complex.html", function(err, data) {
if (err) throw err;
var template = data.toString();
var html = m.to_html(template, view);
var start = new Date().getTime();
var total = 0;
sys.puts(m.to_html(template, view));
while(true) {
m.to_html(template, view);
total++;
if (new Date().getTime() - start > 5000) {
break;
}
}
sys.puts(total / 5);
});