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");
6 var testHtml
= "./testdata/api.html"; //Test HTML file to load
7 var testIterations
= 100; //Number of test loops to run
9 var html
= fs
.readFileSync(testHtml
).toString();
11 function getMillisecs () {
12 return((new Date()).getTime());
15 function timeExecutions (loops
, func
) {
16 var start
= getMillisecs();
21 return(getMillisecs() - start
);
24 sys
.puts("HTML Length: " + html
.length
);
26 sys
.puts("Test 1: " + timeExecutions(testIterations
, function () {
27 // function parseText (data) {
30 // function parseTag (data) {
33 // function parseAttrib (data) {
36 // function parseComment (data) {
39 var data
= html
.split("");
44 while (data
.meta
.length
> data
.meta
.pos
&& data
[data
.meta
.pos
++] !== "");
45 // sys.puts("Found: " + [data.meta.pos, data[data.meta.pos]]);
48 sys
.puts("Test 2: " + timeExecutions(testIterations
, function () {
50 var dataLen
= data
.length
;
52 while (dataLen
> pos
&& data
.charAt(pos
++) !== "");
53 // sys.puts("Found: " + [pos, data.charAt(pos)]);