forked from xmppo/node-expat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.js
More file actions
40 lines (37 loc) · 862 Bytes
/
bench.js
File metadata and controls
40 lines (37 loc) · 862 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
34
35
36
37
38
39
40
var sys = require('sys');
var node_xml = require("node-xml");
var libxml = require("libxmljs");
var expat = require('./lib/node-expat');
function NodeXmlParser() {
var parser = new node_xml.SaxParser(function(cb) { });
this.parse = function(s) {
parser.parseString(s);
};
}
function LibXmlJsParser() {
var parser = new libxml.SaxPushParser(function(cb) { });
this.parse = function(s) {
parser.push(s, false);
};
}
function ExpatParser() {
var parser = new expat.Parser();
this.parse = function(s) {
parser.parse(s, false);
};
}
//var p = new NodeXmlParser();
//var p = new LibXmlJsParser();
var p = new ExpatParser();
p.parse("<r>");
var nEl = 0;
function d() {
p.parse("<foo bar='baz'>quux</foo>");
nEl++;
setTimeout(d, 0);
}
d();
setInterval(function() {
sys.puts(nEl + " el/s");
nEl = 0;
}, 1000);