Created
February 10, 2012 13:13
-
-
Save eungju/1789606 to your computer and use it in GitHub Desktop.
test.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| <html> | |
| <body id="container"> | |
| <script type="text/javascript"> | |
| function drawPaths(canvas) { | |
| var ctx = canvas.getContext('2d'); | |
| ctx.rect(0, 0, 256, 256); | |
| ctx.fillStyle = "#FFFFFF"; | |
| ctx.fill(); | |
| ctx.strokeStyle = "#FF0000"; | |
| ctx.lineWidth = 1; | |
| for (var i = 0; i < 50; i++) { | |
| ctx.beginPath(); | |
| ctx.moveTo(Math.floor(Math.random() * 256), Math.floor(Math.random() * 256)); | |
| for (var j = 0; j < 49; j++) { | |
| ctx.lineTo(Math.floor(Math.random() * 256), Math.floor(Math.random() * 256)); | |
| } | |
| ctx.closePath(); | |
| ctx.stroke(); | |
| } | |
| } | |
| var container = document.getElementById('container'); | |
| var s = new Date(); | |
| for (var n = 0; n < 100; n++) { | |
| var canvas = document.createElement('canvas'); | |
| canvas.width = 256; | |
| canvas.height = 256; | |
| container.appendChild(canvas); | |
| drawPaths(canvas); | |
| } | |
| var e = new Date(); | |
| alert(n / ((e - s) / 1000)); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment