gecko/testing/performance/talos/page_load_test/jss/object-regexp-60.html

264 lines
4.9 KiB
HTML
Raw Normal View History

<html><head>
<!-- MOZ_INSERT_CONTENT_HOOK -->
<script src = runner.js></script>
<script>
var onlyName = 'Compiled Capture Replace with Upperase Capture Function', onlyNum = 32768;
function thisTest() {
startTest("object-regexp");
// Try to force real results
var str = "", tmp, ret, re;
for ( var i = 0; i < 16384; i++ )
str += String.fromCharCode( (25 * Math.random()) + 97 );
for ( var i = 16384; i <= 131072; i *= 2 ) (function(i){
// TESTS: split
// Note: These tests are really slow, so we're running them for smaller
// test sets only.
if ( i <= 32768 ) {
re = //;
tmp = str;
test( "Compiled Object Empty Split", i, function(){
ret = tmp.split( re );
});
re = /a/;
tmp = str;
test( "Compiled Object Char Split", i, function(){
ret = tmp.split( re );
});
re = /.*/;
tmp = str;
test( "Compiled Object Variable Split", i, function(){
ret = tmp.split( re );
});
}
// TESTS: Compiled RegExps
re = /aaaaaaaaaa/g;
tmp = str;
test( "Compiled Match", i, function(){
ret = tmp.match( re );
});
tmp = str;
test( "Compiled Test", i, function(){
ret = re.test( tmp );
});
tmp = str;
test( "Compiled Empty Replace", i, function(){
ret = tmp.replace( re, "" );
});
tmp = str;
test( "Compiled 12 Char Replace", i, function(){
ret = tmp.replace( re, "asdfasdfasdf" );
});
re = new RegExp("aaaaaaaaaa", "g");
tmp = str;
test( "Compiled Object Match", i, function(){
ret = tmp.match( re );
});
tmp = str;
test( "Compiled Object Test", i, function(){
ret = re.test( tmp );
});
tmp = str;
test( "Compiled Object Empty Replace", i, function(){
ret = tmp.replace( re, "" );
});
tmp = str;
test( "Compiled Object 12 Char Replace", i, function(){
ret = tmp.replace( re, "asdfasdfasdf" );
});
tmp = str;
test( "Compiled Object 12 Char Replace Function", i, function(){
ret = tmp.replace( re, function(all){
return "asdfasdfasdf";
});
});
// TESTS: Variable Length
re = /a.*a/;
tmp = str;
test( "Compiled Variable Match", i, function(){
ret = tmp.match( re );
});
tmp = str;
test( "Compiled Variable Test", i, function(){
ret = re.test( tmp );
});
tmp = str;
test( "Compiled Variable Empty Replace", i, function(){
ret = tmp.replace( re, "" );
});
tmp = str;
test( "Compiled Variable 12 Char Replace", i, function(){
ret = tmp.replace( re, "asdfasdfasdf" );
});
re = new RegExp("aaaaaaaaaa", "g");
tmp = str;
test( "Compiled Variable Object Match", i, function(){
ret = tmp.match( re );
});
tmp = str;
test( "Compiled Variable Object Test", i, function(){
ret = re.test( tmp );
});
tmp = str;
test( "Compiled Variable Object Empty Replace", i, function(){
ret = tmp.replace( re, "" );
});
tmp = str;
test( "Compiled Variable Object 12 Char Replace", i, function(){
ret = tmp.replace( re, "asdfasdfasdf" );
});
tmp = str;
test( "Compiled Variable Object 12 Char Replace Function", i, function(){
ret = tmp.replace( re, function(all){
return "asdfasdfasdf";
});
});
// TESTS: Capturing
re = /aa(b)aa/g;
tmp = str;
test( "Compiled Capture Match", i, function(){
ret = tmp.match( re );
});
tmp = str;
test( "Compiled Capture Replace", i, function(){
ret = tmp.replace( re, "asdfasdfasdf" );
});
tmp = str;
test( "Compiled Capture Replace with Capture", i, function(){
ret = tmp.replace( re, "asdf\\1asdfasdf" );
});
tmp = str;
test( "Compiled Capture Replace with Capture Function", i, function(){
ret = tmp.replace( re, function(all,capture){
return "asdf" + capture + "asdfasdf";
});
});
tmp = str;
test( "Compiled Capture Replace with Upperase Capture Function", i, function(){
ret = tmp.replace( re, function(all,capture){
return capture.toUpperCase();
});
});
// TESTS: Uncompiled RegExps
tmp = str;
test( "Uncompiled Match", i, function(){
ret = tmp.match( /aaaaaaaaaa/g );
});
tmp = str;
test( "Uncompiled Test", i, function(){
ret = (/aaaaaaaaaa/g).test( tmp );
});
tmp = str;
test( "Uncompiled Empty Replace", i, function(){
ret = tmp.replace( /aaaaaaaaaa/g, "" );
});
tmp = str;
test( "Uncompiled 12 Char Replace", i, function(){
ret = tmp.replace( /aaaaaaaaaa/g, "asdfasdfasdf" );
});
tmp = str;
test( "Uncompiled Object Match", i, function(){
ret = tmp.match( new RegExp("aaaaaaaaaa", "g") );
});
tmp = str;
test( "Uncompiled Object Test", i, function(){
ret = (new RegExp("aaaaaaaaaa", "g")).test( tmp );
});
tmp = str;
test( "Uncompiled Object Empty Replace", i, function(){
ret = tmp.replace( new RegExp("aaaaaaaaaa", "g"), "" );
});
tmp = str;
test( "Uncompiled Object 12 Char Replace", i, function(){
ret = tmp.replace( new RegExp("aaaaaaaaaa", "g"), "asdfasdfasdf" );
});
// Double the length of the string
str += str;
})(i);
endTest();
}
</script>
<body onload="thisTest()"></body></html>