-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbench.js
More file actions
33 lines (28 loc) · 746 Bytes
/
bench.js
File metadata and controls
33 lines (28 loc) · 746 Bytes
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
var juri = require("./juri.js")(),
i,
obj = { id: 42, name: "Somebody", email: [
"hello@there.com", "what@else.com"
], params: { role: "follower", status: "online" } },
jstr = juri.encode(obj),
json = JSON.stringify(obj),
t;
t = process.hrtime();
for (i = 0; i < 10000; i++) {
jstr = juri.encode(obj);
}
console.log("Juri encode", process.hrtime(t));
t = process.hrtime();
for (i = 0; i < 10000; i++) {
obj = juri.decode(jstr);
}
console.log("Juri decode", process.hrtime(t));
t = process.hrtime();
for(i = 0; i < 10000; i++) {
json = JSON.stringify(obj);
}
console.log("JSON encode", process.hrtime(t));
t = process.hrtime();
for(i = 0; i < 10000; i++) {
obj = JSON.parse(json);
}
console.log("JSON decode", process.hrtime(t));