Files
nyc-bookstores/node_modules/cheerio/node_modules/htmlparser2/tests/99-benchmark.js
2013-05-27 13:45:59 -07:00

26 lines
779 B
JavaScript

var multiply = function(text){
return Array(5e3+1).join(text);
},
tests = {
self_closing: multiply("<br/>"),
tag: multiply("<tag foo=bar foobar> Text </tag>"),
comment: multiply("<!-- this is <<a> comment -->"),
directive: multiply("<?foo bar?>"),
special: multiply("<script> THIS IS <SPECIAL> </script>"),
xml: multiply("<!directive><tag attr='value'> text <!--Comment<>--></tag>")
},
empty = function(){},
cbs = {};
require("./test-helper.js").EVENTS.forEach(function(name){
cbs["on" + name] = empty;
});
var parser = new (require("../lib/Parser.js"))(cbs),
ben = require("ben");
Object.keys(tests).forEach(function(name){
console.log("Test", name, "took", ben(150, function(){
parser.parseComplete(tests[name]);
}));
});