Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Integrate xStats performance monitor.

  • Loading branch information...
commit e955da52d67e6943e6e3ae9262ea34f4f90fad0d 1 parent a5ed1f2
@tobytailor tobytailor authored
View
3  .gitmodules
@@ -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
View
6 examples/inspector/inspector.html
@@ -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>
1  lib/xstats
@@ -0,0 +1 @@
+Subproject commit b00277ea4a733145e01cb68c159d689f703ab2aa
@jhiswin
jhiswin added a note

This commit reftag appears to be invalid
I had to revert to another commit to get it to update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
40 src/swf/renderer.js
@@ -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);
})();
Please sign in to comment.
Something went wrong with that request. Please try again.