From ca7888c93d7bb4fc2d4dbe7a92f7c05c9e2be1c6 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 6 Jun 2015 13:11:30 +0100 Subject: [PATCH] r13 --- README.md | 10 ++++++++-- bower.json | 2 +- build/stats.min.js | 9 ++++----- src/Stats.js | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d33db0d..f165186 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ var update = function () { // monitored code goes here stats.end(); - + requestAnimationFrame( update ); }; @@ -54,7 +54,13 @@ javascript:(function(){var script=document.createElement('script');script.onload ### Change Log ### -2014 08 11 - **r12** (2,310 KB, gzip: 1,087 B) +2015 06 06 - **r13** (2,052 KB, gzip: 964 B) + +* Use `performance.now()` when available. (@ribeirobreno) +* Reduced code. (@mrdoob) + + +2014 08 11 - **r12** (2,310 KB, gzip: 952 B) * Browserify support. (@Miha-ha) diff --git a/bower.json b/bower.json index c4fe91e..9200a0a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "stats.js", - "version": "0.0.12", + "version": "0.0.13", "homepage": "https://github.com/mrdoob/stats.js", "description": "JavaScript Performance Monitor", "main": "build/stats.min.js", diff --git a/build/stats.min.js b/build/stats.min.js index 313bbd3..85b86b4 100644 --- a/build/stats.min.js +++ b/build/stats.min.js @@ -1,6 +1,5 @@ // stats.js - http://github.com/mrdoob/stats.js -var Stats=function(){var g;performance&&performance.now?g=performance.now.bind(performance):(Date.now=Date.now||function(){return(new Date).getTime()},g=function(){return Date.now()});var p=g(),q=p,h=0,r=Infinity,t=0,k=0,u=Infinity,v=0,w=0,x=0,f=document.createElement("div");f.id="stats";f.addEventListener("mousedown",function(b){b.preventDefault();y(++x%2)},!1);f.style.cssText="width:80px;opacity:0.9;cursor:pointer";var a=document.createElement("div");a.id="fps";a.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#002"; -f.appendChild(a);var l=document.createElement("div");l.id="fpsText";l.style.cssText="color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";l.innerHTML="FPS";a.appendChild(l);var c=document.createElement("div");c.id="fpsGraph";c.style.cssText="position:relative;width:74px;height:30px;background-color:#0ff";for(a.appendChild(c);74>c.children.length;){var m=document.createElement("span");m.style.cssText="width:1px;height:30px;float:left;background-color:#113"; -c.appendChild(m)}var d=document.createElement("div");d.id="ms";d.style.cssText="padding:0 0 3px 3px;text-align:left;background-color:#020;display:none";f.appendChild(d);var n=document.createElement("div");n.id="msText";n.style.cssText="color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px";n.innerHTML="MS";d.appendChild(n);var e=document.createElement("div");e.id="msGraph";e.style.cssText="position:relative;width:74px;height:30px;background-color:#0f0"; -for(d.appendChild(e);74>e.children.length;)m=document.createElement("span"),m.style.cssText="width:1px;height:30px;float:left;background-color:#131",e.appendChild(m);var y=function(b){x=b;switch(x){case 0:a.style.display="block";d.style.display="none";break;case 1:a.style.display="none",d.style.display="block"}};return{REVISION:12,domElement:f,setMode:y,begin:function(){p=g()},end:function(){var b=g();h=b-p;r=Math.min(r,h);t=Math.max(t,h);n.textContent=(h|0)+" MS ("+(r|0)+"-"+(t|0)+")";var a=Math.min(30, -30-h/200*30);e.appendChild(e.firstChild).style.height=a+"px";w++;b>q+1E3&&(k=Math.round(1E3*w/(b-q)),u=Math.min(u,k),v=Math.max(v,k),l.textContent=k+" FPS ("+u+"-"+v+")",a=Math.min(30,30-k/100*30),c.appendChild(c.firstChild).style.height=a+"px",q=b,w=0);return b},update:function(){p=this.end()}}};"object"===typeof module&&(module.exports=Stats); +var Stats=function(){function a(b,a,c){b=document.createElement(b);b.id=a;b.style.cssText=c;return b}var m=performance&&performance.now?performance.now.bind(performance):Date.now,k=m(),n=k,c=0,p=Infinity,q=0,d=0,r=Infinity,t=0,u=0,v=0,l=a("div","stats","width:80px;opacity:0.9;cursor:pointer");l.addEventListener("mousedown",function(b){b.preventDefault();z(++v%2)},!1);var e=a("div","fps","padding:0 0 3px 3px;text-align:left;background:#002");l.appendChild(e);var w=a("div","fpsText","color:#0ff;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px"); +w.innerHTML="FPS";e.appendChild(w);var f=a("div","fpsGraph","position:relative;width:74px;height:30px;background:#0ff");for(e.appendChild(f);74>f.children.length;){var x=a("span","","width:1px;height:30px;float:left;background:#113");f.appendChild(x)}var g=a("div","ms","padding:0 0 3px 3px;text-align:left;background:#020;display:none");l.appendChild(g);var y=a("div","msText","color:#0f0;font-family:Helvetica,Arial,sans-serif;font-size:9px;font-weight:bold;line-height:15px");y.innerHTML="MS";g.appendChild(y); +var h=a("div","msGraph","position:relative;width:74px;height:30px;background:#0f0");for(g.appendChild(h);74>h.children.length;)x=a("span","","width:1px;height:30px;float:left;background:#131"),h.appendChild(x);var z=function(b){v=b;switch(v){case 0:e.style.display="block";g.style.display="none";break;case 1:e.style.display="none",g.style.display="block"}};return{REVISION:13,domElement:l,setMode:z,begin:function(){k=m()},end:function(){var b=m();c=b-k;p=Math.min(p,c);q=Math.max(q,c);y.textContent= +(c|0)+" MS ("+(p|0)+"-"+(q|0)+")";var a=Math.min(30,30-c/200*30);h.appendChild(h.firstChild).style.height=a+"px";u++;b>n+1E3&&(d=Math.round(1E3*u/(b-n)),r=Math.min(r,d),t=Math.max(t,d),w.textContent=d+" FPS ("+r+"-"+t+")",a=Math.min(30,30-d/100*30),f.appendChild(f.firstChild).style.height=a+"px",n=b,u=0);return b},update:function(){k=this.end()}}};"object"===typeof module&&(module.exports=Stats); diff --git a/src/Stats.js b/src/Stats.js index 192505d..7c72edb 100644 --- a/src/Stats.js +++ b/src/Stats.js @@ -82,7 +82,7 @@ var Stats = function () { return { - REVISION: 12, + REVISION: 13, domElement: container,