Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html lang="en-US">
- <head>
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <a href="javascript:go()">Begin Test</a><br />
- <canvas id="test_canvas" width="800" height="800"></canvas>
- <pre id="out"></pre>
- <script type="text/javascript">
- var out = document.getElementById('out');
- var cvs = document.getElementById('test_canvas');
- var ctx = cvs.getContext('2d');
- ctx.fillStyle = 'red';
- ctx.fillRect(10,10,790,790);
- // x, y, width, height, iterations
- var tests = [
- [10,10,1,1,100],
- [10,10,1,1,500],
- [10,10,50,50,100],
- [10,10,50,50,500],
- [10,10,780,780,10],
- [10,10,780,780,50],
- ];
- function bench(x,y,w,h,count) {
- var t = (new Date());
- for (var i=0; i < count; i++) ctx.getImageData(x,y,w,h);
- return (new Date()) - t;
- }
- function go() {
- var len = tests.length, output = [];
- for (var i=0; i < len; i++) {
- var time = bench.apply({},tests[i]);
- var mean = (time/tests[i][4]).toFixed(2);
- output.push(tests[i].toString() + ' total: ' + time + 'ms, mean: ' + mean + 'ms');
- }
- var str = navigator.userAgent + "\n" + output.join("\n");
- out.innerHTML = str;
- console.log(str);
- }
- /*
- Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1
- 10,10,1,1,100 total: 1ms, mean: 0.01ms
- 10,10,1,1,500 total: 5ms, mean: 0.01ms
- 10,10,50,50,100 total: 5ms, mean: 0.05ms
- 10,10,50,50,500 total: 24ms, mean: 0.05ms
- 10,10,780,780,10 total: 87ms, mean: 8.70ms
- 10,10,780,780,50 total: 487ms, mean: 9.74ms
- Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; ... )
- 10,10,1,1,100 total: 14ms, mean: 0.14ms
- 10,10,1,1,500 total: 71ms, mean: 0.14ms
- 10,10,50,50,100 total: 24ms, mean: 0.24ms
- 10,10,50,50,500 total: 116ms, mean: 0.23ms
- 10,10,780,780,10 total: 213ms, mean: 21.30ms
- 10,10,780,780,50 total: 979ms, mean: 19.58ms
- Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
- 10,10,1,1,100 total: 1236ms, mean: 12.36ms
- 10,10,1,1,500 total: 6087ms, mean: 12.17ms
- 10,10,50,50,100 total: 1219ms, mean: 12.19ms
- 10,10,50,50,500 total: 6098ms, mean: 12.20ms
- 10,10,780,780,10 total: 154ms, mean: 15.40ms
- 10,10,780,780,50 total: 803ms, mean: 16.06ms
- http://chart.apis.google.com/chart?chxl=1:|1x1*100|1x1*500|50x50*100|50x50*100|780x780*10|780*780*50
- &chxr=0,0,25&chxt=y,x&chbh=a&chs=440x220&cht=bvg&chco=4D89F9,C6D9FD,FF9900&chds=0,25,0,25,0,25
- &chd=t:0.1,0.1,0.05,0.05,8.7,9.74|0.14,0.14,0.24,0.23,21.3,19.58|12.36,12.17,12.19,12.2,15.4,16.06
- &chdl=C14|IE9|FF7&chdlp=t&chg=0,10&chtt=Canvas+getImageData()+Performance
- */
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement