initial commit
[JIRC.git] / node_modules / jsdom / node_modules / htmlparser / newparser.js
1 //node --prof --prof_auto profile.js
2 //deps/v8/tools/mac-tick-processor v8.log
3 var sys = require("sys");
4 var fs = require("fs");
5
6 var testHtml = "./testdata/api.html"; //Test HTML file to load
7 var testIterations = 100; //Number of test loops to run
8
9 var html = fs.readFileSync(testHtml).toString();
10
11 function getMillisecs () {
12 return((new Date()).getTime());
13 }
14
15 function timeExecutions (loops, func) {
16 var start = getMillisecs();
17
18 while (loops--)
19 func();
20
21 return(getMillisecs() - start);
22 }
23
24 sys.puts("HTML Length: " + html.length);
25
26 sys.puts("Test 1: " + timeExecutions(testIterations, function () {
27 // function parseText (data) {
28 // //
29 // }
30 // function parseTag (data) {
31 // //
32 // }
33 // function parseAttrib (data) {
34 // //
35 // }
36 // function parseComment (data) {
37 // //
38 // }
39 var data = html.split("");
40 data.meta = {
41 length: data.length
42 , pos: 0
43 }
44 while (data.meta.length > data.meta.pos && data[data.meta.pos++] !== "");
45 // sys.puts("Found: " + [data.meta.pos, data[data.meta.pos]]);
46 }) + "ms");
47
48 sys.puts("Test 2: " + timeExecutions(testIterations, function () {
49 var data = html;
50 var dataLen = data.length;
51 var pos = 0;
52 while (dataLen > pos && data.charAt(pos++) !== "");
53 // sys.puts("Found: " + [pos, data.charAt(pos)]);
54 }) + "ms");