OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <!-- |
| 6 |
| 7 /* |
| 8 ** Copyright (c) 2012 The Khronos Group Inc. |
| 9 ** |
| 10 ** Permission is hereby granted, free of charge, to any person obtaining a |
| 11 ** copy of this software and/or associated documentation files (the |
| 12 ** "Materials"), to deal in the Materials without restriction, including |
| 13 ** without limitation the rights to use, copy, modify, merge, publish, |
| 14 ** distribute, sublicense, and/or sell copies of the Materials, and to |
| 15 ** permit persons to whom the Materials are furnished to do so, subject to |
| 16 ** the following conditions: |
| 17 ** |
| 18 ** The above copyright notice and this permission notice shall be included |
| 19 ** in all copies or substantial portions of the Materials. |
| 20 ** |
| 21 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 22 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 23 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 24 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 25 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 26 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 27 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 28 */ |
| 29 |
| 30 --> |
| 31 <link rel="stylesheet" type="text/css" href="../unit.css" /> |
| 32 <script type="application/x-javascript" src="../unit.js"></script> |
| 33 <script type="application/x-javascript" src="../util.js"></script> |
| 34 <script type="application/x-javascript"> |
| 35 |
| 36 Tests.autorun = false; |
| 37 Tests.message = "This might take a second or two (or ten)"; |
| 38 |
| 39 Tests.testMatrixMultiply = function() { |
| 40 time("testMatrixMultiply", function() { |
| 41 var mat = Matrix.identity; |
| 42 for (var i=0; i<1000000; i++) |
| 43 Matrix.mul4x4(mat, mat); |
| 44 }); |
| 45 } |
| 46 Tests.testTransformStack = function() { |
| 47 time("testTransformStack", function() { |
| 48 var j = 0; |
| 49 for (var i=0; i<1000; i++) { |
| 50 var t = new Date().getTime(); |
| 51 var pmat = Matrix.perspective(30, 600/400, 1, 100+(t%1000)); |
| 52 var look = Matrix.lookAt([4,-1,8], [-0.2,0+(t%1000),0], [0,1,0]); |
| 53 var rot = Matrix.rotate((t/400) % (2*Math.PI), [0, 1+(t%1000), 1]); |
| 54 var trans = Matrix.translate3(0, Math.cos(t/1000)*1, Math.sin(t/1000
)*3); |
| 55 var sca = Matrix.scale1(0.6+(t%1000)); |
| 56 var vmat = Matrix.identity; |
| 57 vmat = Matrix.mul4x4(vmat, pmat); |
| 58 vmat = Matrix.mul4x4(vmat, look); |
| 59 vmat = Matrix.mul4x4(vmat, trans); |
| 60 vmat = Matrix.mul4x4(vmat, sca); |
| 61 vmat = Matrix.mul4x4(vmat, rot); |
| 62 j += vmat.length; |
| 63 } |
| 64 Tests.j = j; |
| 65 }); |
| 66 } |
| 67 |
| 68 |
| 69 </script> |
| 70 <style>canvas{ position:absolute; }</style> |
| 71 </head><body> |
| 72 <h3>1000000x JavaScript Matrix.mul4x4</h3> |
| 73 <p id="testMatrixMultiply"></p> |
| 74 <h3>1000x JavaScript transform stack</h3> |
| 75 <p id="testTransformStack"></p> |
| 76 </body></html> |
| 77 |
OLD | NEW |