Skip to content

Instantly share code, notes, and snippets.

@otiai10
Created September 22, 2013 12:22
Show Gist options
  • Save otiai10/6659402 to your computer and use it in GitHub Desktop.
Save otiai10/6659402 to your computer and use it in GitHub Desktop.
overheading for HTMLDOM to jQueryObj
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
var samples = {
1 : 1000,
2 : 5000,
3 : 10000,
4 : 20000,
5 : 40000,
6 : 80000,
7 : 160000,
8 : 320000,
9 : 640000,
10 : 1280000
};
var render = function(count, before, after){
var str = '<tr><td>' + count + '</td><td>' + (after - before) + '</td></tr>';
$('#result').append(str);
}
$(function(){
for(var k in samples){
var sample = samples[k];
var i = 0,
before = Date.now(),
after = null;
while(i<sample){
$('div');
i++;
if(i == sample - 1){
after = Date.now();
render(sample, before, after);
}
}
}
});
</script>
</head>
<body>
<div id="test">
<p>test</p>
</div>
<table id="result">
<tr><th>回数</th><th>時間(msec)</th></tr>
</table>
</body>
</head>
@otiai10
Copy link
Author

otiai10 commented Sep 22, 2013

result

test

回数  時間(msec)
1000    6
5000    24
10000   41
20000   73
40000   148
80000   294
160000  611
320000  1161
640000  2315
1280000 4683

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment