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 |
| 11 Tests.testInterval = function() { |
| 12 document.getElementById('dtMax').textContent = "Running, please wait..."; |
| 13 setTimeout(function() { |
| 14 var t0 = new Date().getTime(); |
| 15 var t = t0; |
| 16 var dtMax = 0; |
| 17 var frames = []; |
| 18 var iv; |
| 19 iv = setInterval(function() { |
| 20 if (t > t0 + 10000) { |
| 21 var hist = []; |
| 22 var dtMed = 0, maxi = [0, 0]; |
| 23 for (var i=0; i<dtMax; i++) hist[i] = 0; |
| 24 for (var i=0; i<frames.length; i++) |
| 25 hist[frames[i]]++; |
| 26 for (var i=0; i<hist.length; i++) |
| 27 if (hist[i] > maxi[1]) maxi = [i, hist[i]]; |
| 28 dtMed = maxi[0]; |
| 29 var dtAvg = frames.reduce(function(s,i){return s + i;})/frames.l
ength; |
| 30 document.getElementById('dtMax').textContent = "Longest frame: "
+ dtMax + " ms. Average frame: " + Math.floor(dtAvg*100)*0.01 + " ms. Median fr
ame: " + dtMed + " ms."; |
| 31 clearInterval(iv); |
| 32 var c = document.getElementById('dtCanvas'); |
| 33 c.width = frames.length; |
| 34 c.height = dtMax; |
| 35 var ctx = c.getContext('2d'); |
| 36 for (var i=0; i<frames.length; i++) |
| 37 ctx.fillRect(i,0,1,frames[i]); |
| 38 } |
| 39 var t1 = new Date().getTime(); |
| 40 if (t1-t > dtMax) dtMax = t1-t; |
| 41 frames.push(t1-t); |
| 42 t = t1; |
| 43 var rot = Matrix.rotate((t/400) % (2*Math.PI), [0, 1+(t%1000), 1]); |
| 44 var trans = Matrix.translate3(0, Math.cos(t/1000)*1, Math.sin(t/1000
)*3); |
| 45 for (var i=0; i<200; i++) |
| 46 var mat = Matrix.mul4x4(rot, trans); |
| 47 }, 16); |
| 48 }, 0); |
| 49 } |
| 50 |
| 51 </script> |
| 52 <style>canvas{ position:absolute; }</style> |
| 53 </head><body> |
| 54 <h3>10 seconds of 60fps 200x mul4x4, frame time statistics</h3> |
| 55 <p id="dtMax"></p> |
| 56 <canvas id="dtCanvas"></canvas> |
| 57 </body></html> |
| 58 |
OLD | NEW |