OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html><head> |
| 3 <meta charset="utf-8"> |
| 4 <link rel="stylesheet" type="text/css" href="../unit.css" /> |
| 5 <script type="application/x-javascript" src="../unit.js"></script> |
| 6 <script type="application/x-javascript" src="../util.js"></script> |
| 7 <script type="application/x-javascript"> |
| 8 |
| 9 Tests.autorun = false; |
| 10 Tests.message = "This might take a second or two (or ten)"; |
| 11 |
| 12 Tests.testMatrixMultiply = function() { |
| 13 time("testMatrixMultiply", function() { |
| 14 var mat = Matrix.identity; |
| 15 for (var i=0; i<1000000; i++) |
| 16 Matrix.mul4x4(mat, mat); |
| 17 }); |
| 18 } |
| 19 Tests.testTransformStack = function() { |
| 20 time("testTransformStack", function() { |
| 21 var j = 0; |
| 22 for (var i=0; i<1000; i++) { |
| 23 var t = new Date().getTime(); |
| 24 var pmat = Matrix.perspective(30, 600/400, 1, 100+(t%1000)); |
| 25 var look = Matrix.lookAt([4,-1,8], [-0.2,0+(t%1000),0], [0,1,0]); |
| 26 var rot = Matrix.rotate((t/400) % (2*Math.PI), [0, 1+(t%1000), 1]); |
| 27 var trans = Matrix.translate3(0, Math.cos(t/1000)*1, Math.sin(t/1000
)*3); |
| 28 var sca = Matrix.scale1(0.6+(t%1000)); |
| 29 var vmat = Matrix.identity; |
| 30 vmat = Matrix.mul4x4(vmat, pmat); |
| 31 vmat = Matrix.mul4x4(vmat, look); |
| 32 vmat = Matrix.mul4x4(vmat, trans); |
| 33 vmat = Matrix.mul4x4(vmat, sca); |
| 34 vmat = Matrix.mul4x4(vmat, rot); |
| 35 j += vmat.length; |
| 36 } |
| 37 Tests.j = j; |
| 38 }); |
| 39 } |
| 40 |
| 41 |
| 42 </script> |
| 43 <style>canvas{ position:absolute; }</style> |
| 44 </head><body> |
| 45 <h3>1000000x JavaScript Matrix.mul4x4</h3> |
| 46 <p id="testMatrixMultiply"></p> |
| 47 <h3>1000x JavaScript transform stack</h3> |
| 48 <p id="testTransformStack"></p> |
| 49 </body></html> |
| 50 |
OLD | NEW |