Permalink
Browse files

Integrate xStats performance monitor.

  • Loading branch information...
tobytailor committed Nov 15, 2012
1 parent a5ed1f2 commit e955da52d67e6943e6e3ae9262ea34f4f90fad0d
Showing with 10 additions and 40 deletions.
  1. +3 −0 .gitmodules
  2. +6 −0 examples/inspector/inspector.html
  3. +1 −0 lib/xstats
  4. +0 −40 src/swf/renderer.js
View
@@ -4,3 +4,6 @@
[submodule "lib/DataView.js"]
path = lib/DataView.js
url = https://github.com/davidflanagan/DataView.js.git
+[submodule "lib/xstats"]
+ path = lib/xstats
+ url = https://github.com/bestiejs/xstats.js.git
@@ -11,6 +11,7 @@
<script src="jquery.min.js"></script>
<script src="../../lib/DataView.js/DataView.js"></script>
<script src="../../lib/Kanvas/kanvas.js"></script>
+ <script src="../../lib/xstats/xstats.js"></script>
<!-- Load SWF Dependencies -->
<script src="../../src/swf/util.js"></script>
@@ -177,5 +178,10 @@
SHUMWAY_ROOT = "../../src/";
</script>
+ <script>
+ var stats = new xStats;
+ document.body.appendChild(stats.element);
+ </script>
+
</body>
</html>
Submodule xstats added at b00277
View
@@ -258,45 +258,6 @@ function renderStage(stage, ctx) {
window.msRequestAnimationFrame ||
window.setTimeout;
- var FPS = (function () {
- var width = Math.max(ctx.canvas.width / 5, 100);
- var height = width / 8;
- var sampleWidth = 2;
- var sampleCount = width / (sampleWidth + 1);
- var last = null;
- var samples = [];
- var max = 0;
-
- return {
- tick: function () {
- var curr = new Date();
- if (last) {
- if (samples.length > sampleCount) {
- samples.shift();
- }
- var elapsed = curr - last;
- samples.push(elapsed);
- var sum = 0;
- for (var i = 0; i < samples.length; i++) {
- sum += samples[i];
- max = Math.max(max, samples[i]);
- }
- var avg = sum / samples.length;
- var xOffset = ctx.canvas.width - width;
- var yOffset = height;
- ctx.clearRect(xOffset, yOffset, width, height);
- for (var i = 0; i < samples.length; i++) {
- var scaledSample = (samples[i] / (2 * avg));
- ctx.fillRect(xOffset + i * (sampleWidth + 1), yOffset, sampleWidth, - scaledSample * height);
- }
- ctx.font = "6pt Verdana";
- ctx.fillText("FPS: " + (1000 / avg).toFixed(2), xOffset, height + 15);
- }
- last = curr;
- }
- };
- })();
-
(function draw() {
var now = +new Date;
if (now - frameTime >= maxDelay) {
@@ -307,7 +268,6 @@ function renderStage(stage, ctx) {
visitContainer(stage, new EnterFrameVisitor(ctx));
visitContainer(stage, new RenderVisitor(ctx));
visitContainer(stage, new ExitFrameVisitor());
- FPS.tick();
}
requestAnimationFrame(draw);
})();

0 comments on commit e955da5

Please sign in to comment.