silverstripe-framework/admin/javascript/jquery-changetracker/spec/.tmp_speed.html.70283~

105 lines
3.2 KiB
Plaintext

<html>
<head>
<link type="text/css" rel="stylesheet" href="../vendor/jspec/lib/jspec.css" />
<script src="../vendor/jquery-1.3.2.js"></script>
<script src="../vendor/jquery.livequery-1.0.3.js"></script>
<script src="../vendor/jspec/lib/jspec.js"></script>
<script src="../vendor/jspec/lib/jspec.jquery.js"></script>
<script src="../src/jquery.dat.js"></script>
<script src="../src/jquery.specifity.js"></script>
<script src="../src/jquery.concrete.js"></script>
<script src="../src/jquery.fastis.js"></script>
<script>
function run() {
var selectors = [
'#a',
'.b',
'.b.c',
'#d > #a',
'#e #a',
'#e > #d > #a',
'#base #d #a',
'#a ~ #c',
'#a + #b',
'#a:not(#b)',
'.b:not(.d)',
'#e:not(#f) #a:not(#f)'
];
var is = 0, isc = 0, fast = 0, fastc = 0;
var x = 0, y = 0;
function test() {
var selector = selectors[x];
if (y == 0) {
var el = $(selector);
var start = (new Date).getTime()
for (var j = 0; j < 10000; j++) {
if (!el.is(selector)) { $('#out').append('<li>'+selector+':good is:ERROR</li>'); return; }
}
var time = (new Date).getTime() - start;
$('#out').append('<li>'+selector+':good is:'+time+'</li>');
is += time; isc += 1; $('#isg').css('width', is/isc + 'px');
y=1;
}
else if (y == 1) {
var el = $(selector);
var start = (new Date).getTime()
for (var j = 0; j < 10000; j++) {
if (!el.fastis(selector)) { $('#out').append('<li>'+selector+':good fastis:ERROR</li>'); return; };
}
var time = (new Date).getTime() - start;
$('#out').append('<li>'+selector+':good fastis:'+time+'</li>');
fast += time; fastc += 1; $('#fastg').css('width', fast/fastc + 'px');
y=2;
}
else if (y==2) {
var el = $('#base');
var start = (new Date).getTime()
for (var j = 0; j < 10000; j++) {
if (el.is(selector)) { $('#out').append('<li>'+selector+':bad is:ERROR</li>'); return; };
}
var time = (new Date).getTime() - start;
$('#out').append('<li>'+selector+':bad is:'+time+'</li>');
is += time; isc += 1; $('#isg').css('width', is/isc + 'px');
y=3;
}
else if (y==3) {
var el = $('#base');
var start = (new Date).getTime()
for (var j = 0; j < 10000; j++) {
if (el.fastis(selector)) { $('#out').append('<li>'+selector+':bad fastis:ERROR</li>'); return; };
}
var time = (new Date).getTime() - start;
$('#out').append('<li>'+selector+':bad fastis:'+time+'</li>');
fast += time; fastc += 1; $('#fastg').css('width', fast/fastc + 'px');
y=0; x += 1;
}
if (x < selectors.length) setTimeout(test,20);
}
test();
}
</script>
</head>
<body class="jspec" onLoad="run();">
<div id='isg' style='height:20px;float:left;clear:left;background:blue;'>Regular is</div>
<div id='fastg' style='height:20px;float:left;clear:left;background:green;'>Fast is</div>
<ul id='out' style='clear:left;'>
</ul>
<div id='base'>
<div id='e'>
<div id='d'>
<div id='a' class='b c'></div>
<div id='b'></div>
<div id='c'></div>
</div>
</div>
</div>
</body>
</html>