From 2e1a2f420dbc1bd3cfb9a34aee4e430bafa74d8b Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 1 May 2010 18:15:48 +0800 Subject: [PATCH 01/14] replaced Bitmap by beginBitmapFill/drawRect --- src/net/hires/debug/Stats.as | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/net/hires/debug/Stats.as b/src/net/hires/debug/Stats.as index 29c65ed..12cc0d6 100644 --- a/src/net/hires/debug/Stats.as +++ b/src/net/hires/debug/Stats.as @@ -1,4 +1,4 @@ -/** +/** * stats.as * http://github.com/mrdoob/stats.as * @@ -13,11 +13,11 @@ package net.hires.debug { - import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; + import flash.geom.Matrix; import flash.geom.Rectangle; import flash.system.System; import flash.text.StyleSheet; @@ -41,7 +41,7 @@ package net.hires.debug protected var mem : Number; protected var mem_max : Number; - protected var graph : Bitmap; + protected var graph : BitmapData; protected var rectangle : Rectangle; protected var fps_graph : uint; @@ -85,9 +85,6 @@ package net.hires.debug text.selectable = false; text.mouseEnabled = false; - graph = new Bitmap(); - graph.y = 50; - rectangle = new Rectangle( WIDTH - 1, 0, 1, HEIGHT - 50 ); addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true); @@ -102,8 +99,9 @@ package net.hires.debug addChild(text); - graph.bitmapData = new BitmapData(WIDTH, HEIGHT - 50, false, theme.bg); - addChild(graph); + graph = new BitmapData(WIDTH, HEIGHT - 50, false, theme.bg); + graphics.beginBitmapFill (graph, new Matrix (1, 0, 0, 1, 0, 50)); + graphics.drawRect(0, 50, WIDTH, HEIGHT - 50); addEventListener(MouseEvent.CLICK, onClick); addEventListener(Event.ENTER_FRAME, update); @@ -116,7 +114,7 @@ package net.hires.debug while(numChildren > 0) removeChildAt(0); - graph.bitmapData.dispose(); + graph.dispose(); removeEventListener(MouseEvent.CLICK, onClick); removeEventListener(Event.ENTER_FRAME, update); @@ -136,13 +134,13 @@ package net.hires.debug mem_graph = Math.min( graph.height, Math.sqrt( Math.sqrt( mem * 5000 ) ) ) - 2; mem_max_graph = Math.min( graph.height, Math.sqrt( Math.sqrt( mem_max * 5000 ) ) ) - 2; - graph.bitmapData.scroll( -1, 0 ); + graph.scroll( -1, 0 ); - graph.bitmapData.fillRect( rectangle , theme.bg ); - graph.bitmapData.setPixel( graph.width - 1, graph.height - fps_graph, theme.fps); - graph.bitmapData.setPixel( graph.width - 1, graph.height - ( ( timer - ms ) >> 1 ), theme.ms ); - graph.bitmapData.setPixel( graph.width - 1, graph.height - mem_graph, theme.mem); - graph.bitmapData.setPixel( graph.width - 1, graph.height - mem_max_graph, theme.memmax); + graph.fillRect( rectangle , theme.bg ); + graph.setPixel( graph.width - 1, graph.height - fps_graph, theme.fps); + graph.setPixel( graph.width - 1, graph.height - ( ( timer - ms ) >> 1 ), theme.ms ); + graph.setPixel( graph.width - 1, graph.height - mem_graph, theme.mem); + graph.setPixel( graph.width - 1, graph.height - mem_max_graph, theme.memmax); xml.fps = "FPS: " + fps + " / " + stage.frameRate; xml.mem = "MEM: " + mem; From db87419a83a97107517e56923a7a9a58d3f6da2e Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Wed, 5 May 2010 08:05:51 -0700 Subject: [PATCH 02/14] =?UTF-8?q?-=20Removed=20theme=20param=20on=20constr?= =?UTF-8?q?uctor=20(nobody=20was=20really=20using=20it).=20-=20Workaround?= =?UTF-8?q?=20to=20remove=20FDT=20warnings.=20Thx=20=D0=9C=D0=B8=D1=85?= =?UTF-8?q?=D0=B0=D0=B8=D0=BB=20=D0=A7=D0=B5=D1=80=D0=BD=D0=B8=D0=BA=D0=BE?= =?UTF-8?q?=D0=B2!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/net/hires/debug/Stats.as | 131 ++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 62 deletions(-) diff --git a/src/net/hires/debug/Stats.as b/src/net/hires/debug/Stats.as index 12cc0d6..f620f8c 100644 --- a/src/net/hires/debug/Stats.as +++ b/src/net/hires/debug/Stats.as @@ -1,4 +1,4 @@ -/** +/** * stats.as * http://github.com/mrdoob/stats.as * @@ -11,8 +11,8 @@ * **/ -package net.hires.debug -{ +package net.hires.debug { + import flash.display.BitmapData; import flash.display.Sprite; import flash.events.Event; @@ -24,11 +24,11 @@ package net.hires.debug import flash.text.TextField; import flash.utils.getTimer; - public class Stats extends Sprite - { + public class Stats extends Sprite { + protected const WIDTH : uint = 70; protected const HEIGHT : uint = 100; - + protected var xml : XML; protected var text : TextField; @@ -40,42 +40,31 @@ package net.hires.debug protected var ms_prev : uint; protected var mem : Number; protected var mem_max : Number; - + protected var graph : BitmapData; protected var rectangle : Rectangle; - + protected var fps_graph : uint; protected var mem_graph : uint; protected var mem_max_graph : uint; - - protected var theme : Object = { bg: 0x000033, fps: 0xffff00, ms: 0x00ff00, mem: 0x00ffff, memmax: 0xff0070 }; + + protected var colors : Colors = new Colors(); /** * Stats FPS, MS and MEM, all in one. - * - * @param _theme Example: { bg: 0x202020, fps: 0xC0C0C0, ms: 0x505050, mem: 0x707070, memmax: 0xA0A0A0 } */ - public function Stats( _theme : Object = null ) : void - { - if (_theme) - { - if (_theme.bg != null) theme.bg = _theme.bg; - if (_theme.fps != null) theme.fps = _theme.fps; - if (_theme.ms != null) theme.ms = _theme.ms; - if (_theme.mem != null) theme.mem = _theme.mem; - if (_theme.memmax != null) theme.memmax = _theme.memmax; - } + public function Stats() : void { mem_max = 0; xml = FPS:MS:MEM:MAX:; style = new StyleSheet(); - style.setStyle("xml", {fontSize:'9px', fontFamily:'_sans', leading:'-2px'}); - style.setStyle("fps", {color: hex2css(theme.fps)}); - style.setStyle("ms", {color: hex2css(theme.ms)}); - style.setStyle("mem", {color: hex2css(theme.mem)}); - style.setStyle("memMax", {color: hex2css(theme.memmax)}); + style.setStyle('xml', {fontSize:'9px', fontFamily:'_sans', leading:'-2px'}); + style.setStyle('fps', {color: hex2css(colors.fps)}); + style.setStyle('ms', {color: hex2css(colors.ms)}); + style.setStyle('mem', {color: hex2css(colors.mem)}); + style.setStyle('memMax', {color: hex2css(colors.memmax)}); text = new TextField(); text.width = WIDTH; @@ -85,30 +74,32 @@ package net.hires.debug text.selectable = false; text.mouseEnabled = false; - rectangle = new Rectangle( WIDTH - 1, 0, 1, HEIGHT - 50 ); + rectangle = new Rectangle(WIDTH - 1, 0, 1, HEIGHT - 50); addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true); addEventListener(Event.REMOVED_FROM_STAGE, destroy, false, 0, true); + } - private function init(e : Event) : void - { - graphics.beginFill(theme.bg); + private function init(e : Event) : void { + + graphics.beginFill(colors.bg); graphics.drawRect(0, 0, WIDTH, HEIGHT); graphics.endFill(); addChild(text); - graph = new BitmapData(WIDTH, HEIGHT - 50, false, theme.bg); - graphics.beginBitmapFill (graph, new Matrix (1, 0, 0, 1, 0, 50)); + graph = new BitmapData(WIDTH, HEIGHT - 50, false, colors.bg); + graphics.beginBitmapFill(graph, new Matrix(1, 0, 0, 1, 0, 50)); graphics.drawRect(0, 50, WIDTH, HEIGHT - 50); addEventListener(MouseEvent.CLICK, onClick); addEventListener(Event.ENTER_FRAME, update); + } - - private function destroy(e : Event) : void - { + + private function destroy(e : Event) : void { + graphics.clear(); while(numChildren > 0) @@ -118,57 +109,73 @@ package net.hires.debug removeEventListener(MouseEvent.CLICK, onClick); removeEventListener(Event.ENTER_FRAME, update); - } + + } - private function update(e : Event) : void - { + private function update(e : Event) : void { + timer = getTimer(); - if( timer - 1000 > ms_prev ) - { + if( timer - 1000 > ms_prev ) { + ms_prev = timer; mem = Number((System.totalMemory * 0.000000954).toFixed(3)); mem_max = mem_max > mem ? mem_max : mem; - fps_graph = Math.min( graph.height, ( fps / stage.frameRate ) * graph.height ); - mem_graph = Math.min( graph.height, Math.sqrt( Math.sqrt( mem * 5000 ) ) ) - 2; - mem_max_graph = Math.min( graph.height, Math.sqrt( Math.sqrt( mem_max * 5000 ) ) ) - 2; + fps_graph = Math.min(graph.height, ( fps / stage.frameRate ) * graph.height); + mem_graph = Math.min(graph.height, Math.sqrt(Math.sqrt(mem * 5000))) - 2; + mem_max_graph = Math.min(graph.height, Math.sqrt(Math.sqrt(mem_max * 5000))) - 2; - graph.scroll( -1, 0 ); + graph.scroll(-1, 0); - graph.fillRect( rectangle , theme.bg ); - graph.setPixel( graph.width - 1, graph.height - fps_graph, theme.fps); - graph.setPixel( graph.width - 1, graph.height - ( ( timer - ms ) >> 1 ), theme.ms ); - graph.setPixel( graph.width - 1, graph.height - mem_graph, theme.mem); - graph.setPixel( graph.width - 1, graph.height - mem_max_graph, theme.memmax); + graph.fillRect(rectangle, colors.bg); + graph.setPixel(graph.width - 1, graph.height - fps_graph, colors.fps); + graph.setPixel(graph.width - 1, graph.height - ( ( timer - ms ) >> 1 ), colors.ms); + graph.setPixel(graph.width - 1, graph.height - mem_graph, colors.mem); + graph.setPixel(graph.width - 1, graph.height - mem_max_graph, colors.memmax); - xml.fps = "FPS: " + fps + " / " + stage.frameRate; - xml.mem = "MEM: " + mem; - xml.memMax = "MAX: " + mem_max; + xml.replace('fps', 'FPS: ' + fps + ' / ' + stage.frameRate + ''); + xml.replace('mem', 'MEM: ' + mem + ''); + xml.replace('memMax', 'MAX: ' + mem_max + ''); fps = 0; + } fps++; - xml.ms = "MS: " + (timer - ms); + xml.replace('ms', 'MS: ' + (timer - ms) + ''); ms = timer; text.htmlText = xml; } - - private function onClick(e : MouseEvent) : void - { + + private function onClick(e : MouseEvent) : void { + mouseY / height > .5 ? stage.frameRate-- : stage.frameRate++; - xml.fps = "FPS: " + fps + " / " + stage.frameRate; + xml.replace('fps', 'FPS: ' + fps + ' / ' + stage.frameRate + ''); text.htmlText = xml; + } - + // .. Utils - - private function hex2css( color : int ) : String - { + + private function hex2css( color : int ) : String { + return "#" + color.toString(16); + } + } + } + +class Colors { + + public var bg : uint = 0x000033; + public var fps : uint = 0xffff00; + public var ms : uint = 0x00ff00; + public var mem : uint = 0x00ffff; + public var memmax : uint = 0xff0070; + +} \ No newline at end of file From 54ead204aa8f4111bf77c7612fc2ac66566b6063 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Wed, 5 May 2010 08:06:53 -0700 Subject: [PATCH 03/14] Removed change log --- README.md | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/README.md b/README.md index 1d0dba9..207bedc 100644 --- a/README.md +++ b/README.md @@ -22,36 +22,4 @@ This class provides a simple info box that will help you monitor your code perfo ### Download ### -[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) - -### Change Log ### - -2009 10 22 - v**2.2** - -* FlipX of graph to be more logic. -* Destroy on Event.REMOVED_FROM_STAGE (thx joshtynjala) - - -2009 03 28 - v**2.1** - -* Theme support. - - -2009 02 21 - v**2.0** - -* changed text system -* added MAX value (Max memory reached). very useful for spotting memory leaks -* removed player version on roll over (let me know if this is a bad idea) -* simplified - - -2009 02 07 - v**1.5** - -* onRemovedFromStage() (thx huihuicn.xu) - - -2008 12 14 - v**1.4** - -* Code optimisations, should take even less CPU -* Fixed ugly drawing when transparent (thx makc.the.great) -* Added Version info on Mouse Over. +[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) \ No newline at end of file From e1ede4288f5cf020ff053d5461edbc669c886904 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Wed, 5 May 2010 09:56:18 -0700 Subject: [PATCH 04/14] --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 207bedc..a5caa01 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ This class provides a simple info box that will help you monitor your code perfo * MEM Memory your code is using, if it increases per frame is VERY wrong. * MAX Maximum memory the application reached. +### Download ### + +[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) + ### How to use ### addChild( new Stats() ); ### Controls ### -* **LEFT CLICK** on the top-half/bottom-half part of the panel to increase/decrease the movie FPS limit. - -### Download ### - -[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) \ No newline at end of file +* **LEFT CLICK** on the top-half/bottom-half part of the panel to increase/decrease the movie FPS limit. \ No newline at end of file From aba7b388a23cadb7f41c9abd9985ca0c10f41490 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Fri, 4 Jun 2010 17:03:45 -0700 Subject: [PATCH 05/14] Reverted xml.replace() to the e4x way. --- src/net/hires/debug/Stats.as | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/net/hires/debug/Stats.as b/src/net/hires/debug/Stats.as index f620f8c..509a083 100644 --- a/src/net/hires/debug/Stats.as +++ b/src/net/hires/debug/Stats.as @@ -134,9 +134,9 @@ package net.hires.debug { graph.setPixel(graph.width - 1, graph.height - mem_graph, colors.mem); graph.setPixel(graph.width - 1, graph.height - mem_max_graph, colors.memmax); - xml.replace('fps', 'FPS: ' + fps + ' / ' + stage.frameRate + ''); - xml.replace('mem', 'MEM: ' + mem + ''); - xml.replace('memMax', 'MAX: ' + mem_max + ''); + xml.fps = "FPS: " + fps + " / " + stage.frameRate; + xml.mem = "MEM: " + mem; + xml.memMax = "MAX: " + mem_max; fps = 0; @@ -144,7 +144,7 @@ package net.hires.debug { fps++; - xml.replace('ms', 'MS: ' + (timer - ms) + ''); + xml.ms = "MS: " + (timer - ms); ms = timer; text.htmlText = xml; @@ -153,7 +153,7 @@ package net.hires.debug { private function onClick(e : MouseEvent) : void { mouseY / height > .5 ? stage.frameRate-- : stage.frameRate++; - xml.replace('fps', 'FPS: ' + fps + ' / ' + stage.frameRate + ''); + xml.fps = "FPS: " + fps + " / " + stage.frameRate; text.htmlText = xml; } From c0a093dcc3a63b2ec012398d3bdedac8047be156 Mon Sep 17 00:00:00 2001 From: David Wilhelm Date: Fri, 4 Jun 2010 23:54:01 -0400 Subject: [PATCH 06/14] added haXe version of Stats --- src/net/hires/debug/Stats.hx | 191 +++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 src/net/hires/debug/Stats.hx diff --git a/src/net/hires/debug/Stats.hx b/src/net/hires/debug/Stats.hx new file mode 100644 index 0000000..c82f4f5 --- /dev/null +++ b/src/net/hires/debug/Stats.hx @@ -0,0 +1,191 @@ +/** + * stats.hx + * http://github.com/mrdoob/stats.as + * + * Released under MIT license: + * http://www.opensource.org/licenses/mit-license.php + * + * How to use: + * + * addChild( new Stats() ); + * + **/ + +package net.hires.debug; + +import flash.display.BitmapData; +import flash.display.Sprite; +import flash.display.Stage; +import flash.events.Event; +import flash.events.MouseEvent; +import flash.geom.Matrix; +import flash.geom.Rectangle; +import flash.system.System; +import flash.text.StyleSheet; +import flash.text.TextField; +import flash.xml.XML; + +import net.hires.debug.Stats; + + +class Stats extends Sprite { + + static inline var GRAPH_WIDTH : Int = 70; + static inline var XPOS : Int = 69;//width - 1 + static inline var GRAPH_HEIGHT : Int = 50; + static inline var TEXT_HEIGHT : Int = 50; + + private var xml : String; + + private var text : TextField; + private var style : StyleSheet; + + private var timer : Int; + private var fps : Int; + private var ms : Int; + private var ms_prev : Int; + private var mem : Float; + private var mem_max : Float; + + private var graph : BitmapData; + private var rectangle : Rectangle; + + private var fps_graph : Int; + private var mem_graph : Int; + private var ms_graph : Int; + private var mem_max_graph : Int; + private var _stage:Stage; + + /** + * Stats FPS, MS and MEM, all in one. + */ + public function new() { + + super(); + mem_max = 0; + fps = 0; + + xml = "FPS:_fps_MS:_ms_MEM:_mem_MAX:_mem_max_"; + + style = new StyleSheet(); + style.setStyle('xml', {fontSize:'9px', fontFamily:'_sans', leading:'-2px'}); + style.setStyle('fps', {color: Colors.fpsCSS }); + style.setStyle('ms', {color: Colors.msCSS }); + style.setStyle('mem', {color: Colors.memCSS }); + style.setStyle('memMax', {color: Colors.memmaxCSS }); + + text = new TextField(); + text.width = GRAPH_WIDTH; + text.height = TEXT_HEIGHT; + text.styleSheet = style; + text.condenseWhite = true; + text.selectable = false; + text.mouseEnabled = false; + + rectangle = new Rectangle(GRAPH_WIDTH - 1, 0, 1, GRAPH_HEIGHT); + + this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true); + this.addEventListener(Event.REMOVED_FROM_STAGE, destroy, false, 0, true); + + } + + private function init(e : Event) { + + _stage = flash.Lib.current.stage; + graphics.beginFill(Colors.bg); + graphics.drawRect(0, 0, GRAPH_WIDTH, TEXT_HEIGHT); + graphics.endFill(); + + this.addChild(text); + + graph = new BitmapData(GRAPH_WIDTH, GRAPH_HEIGHT, false, Colors.bg); + graphics.beginBitmapFill(graph, new Matrix(1, 0, 0, 1, 0, TEXT_HEIGHT)); + graphics.drawRect(0, TEXT_HEIGHT, GRAPH_WIDTH, GRAPH_HEIGHT); + + this.addEventListener(Event.ENTER_FRAME, update); + + } + + private function destroy(e : Event) { + + graphics.clear(); + + while(numChildren > 0) + removeChildAt(0); + + graph.dispose(); + + removeEventListener(Event.ENTER_FRAME, update); + + } + + private function update(e : Event) { + + timer = flash.Lib.getTimer(); + + //after a second has passed + if( timer - 1000 > ms_prev ) { + + mem = System.totalMemory * 0.000000954; + mem_max = mem_max > mem ? mem_max : mem; + + fps_graph = GRAPH_HEIGHT - Std.int( Math.min(GRAPH_HEIGHT, ( fps / _stage.frameRate ) * GRAPH_HEIGHT) ); + + mem_graph = GRAPH_HEIGHT - normalizeMem(mem); + mem_max_graph = GRAPH_HEIGHT - normalizeMem(mem_max); + //milliseconds since last frame -- this fluctuates quite a bit + ms_graph = Std.int( GRAPH_HEIGHT - ( ( timer - ms ) >> 1 )); + graph.scroll(-1, 0); + + graph.fillRect(rectangle, Colors.bg); + graph.lock(); + graph.setPixel(XPOS, fps_graph, Colors.fps); + graph.setPixel(XPOS, mem_graph, Colors.mem); + graph.setPixel(XPOS, mem_max_graph, Colors.memmax); + graph.setPixel(XPOS, ms_graph, Colors.ms); + graph.unlock(); + + updateStats(); + + //reset frame and time counters + fps = 0; + ms_prev = timer; + + return; + } + //increment number of frames which have occurred in current second + fps++; + ms = timer; + + } + + function updateStats() { + + var myxml = xml; + var fpsStr = ' ' + fps + ' / ' + stage.frameRate; + myxml = StringTools.replace(xml, '_fps_', fpsStr); + myxml = StringTools.replace(myxml, '_mem_', ' ' + mem); + myxml = StringTools.replace(myxml, '_mem_max_', ' ' + mem_max); + text.htmlText = StringTools.replace(myxml, '_ms_', ' ' + (timer - ms)); + } + + function normalizeMem(_mem:Float):Int { + return Std.int( Math.min( GRAPH_HEIGHT, Math.sqrt(Math.sqrt(_mem * 5000)) ) - 2); + } + +} + +class Colors { + + public static inline var bg : Int = 0x000033; + public static inline var fps : Int = 0xffff00; + public static inline var ms : Int = 0x00ff00; + public static inline var mem : Int = 0x00ffff; + public static inline var memmax : Int = 0xff0070; + public static inline var bgCSS : String = "#000033"; + public static inline var fpsCSS : String = "#ffff00"; + public static inline var msCSS : String = "#00ff00"; + public static inline var memCSS : String = "#00ffff"; + public static inline var memmaxCSS : String = "#ff0070"; + +} From c4f28fb27884d08d6b5b6161e2ae1af8bd0ae793 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 5 Jun 2010 12:44:00 -0700 Subject: [PATCH 07/14] Direct link to Stats.hx --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a5caa01..551886a 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ This class provides a simple info box that will help you monitor your code perfo ### Download ### [Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) +[Stats.hx](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.hx) (Ported by [David Wilhelm](http://github.com/bigfish)) ### How to use ### From d23dc59e75fe9815c6102ddfd42ae18467675855 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 5 Jun 2010 12:45:40 -0700 Subject: [PATCH 08/14] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 551886a..00c15a1 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This class provides a simple info box that will help you monitor your code perfo ### Download ### -[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) +[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) [Stats.hx](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.hx) (Ported by [David Wilhelm](http://github.com/bigfish)) ### How to use ### From eae3edbf551a19d9177327de21b9ed3fe578a82c Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 5 Jun 2010 12:46:58 -0700 Subject: [PATCH 09/14] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00c15a1..d8ca5cc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This class provides a simple info box that will help you monitor your code perfo ### Download ### -[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) +[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) [Stats.hx](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.hx) (Ported by [David Wilhelm](http://github.com/bigfish)) ### How to use ### From f2aad03570cf3f53a7730ff19e76ddad436e313d Mon Sep 17 00:00:00 2001 From: David Wilhelm Date: Sun, 6 Jun 2010 11:37:24 +0800 Subject: [PATCH 10/14] refactored to use e4x --- src/net/hires/debug/Stats.hx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/net/hires/debug/Stats.hx b/src/net/hires/debug/Stats.hx index c82f4f5..e026e84 100644 --- a/src/net/hires/debug/Stats.hx +++ b/src/net/hires/debug/Stats.hx @@ -25,8 +25,6 @@ import flash.text.StyleSheet; import flash.text.TextField; import flash.xml.XML; -import net.hires.debug.Stats; - class Stats extends Sprite { @@ -35,7 +33,7 @@ class Stats extends Sprite { static inline var GRAPH_HEIGHT : Int = 50; static inline var TEXT_HEIGHT : Int = 50; - private var xml : String; + private var xml : XML; private var text : TextField; private var style : StyleSheet; @@ -65,7 +63,8 @@ class Stats extends Sprite { mem_max = 0; fps = 0; - xml = "FPS:_fps_MS:_ms_MEM:_mem_MAX:_mem_max_"; + + xml = new XML("FPS:MS:MEM:MAX:"); style = new StyleSheet(); style.setStyle('xml', {fontSize:'9px', fontFamily:'_sans', leading:'-2px'}); @@ -145,7 +144,9 @@ class Stats extends Sprite { graph.setPixel(XPOS, ms_graph, Colors.ms); graph.unlock(); - updateStats(); + xml.fps = "FPS: " + fps + " / " + stage.frameRate; + xml.mem = "MEM: " + mem; + xml.memMax = "MAX: " + mem_max; //reset frame and time counters fps = 0; @@ -155,19 +156,14 @@ class Stats extends Sprite { } //increment number of frames which have occurred in current second fps++; + + xml.ms = "MS: " + (timer - ms); ms = timer; + text.htmlText = xml.toString(); } - function updateStats() { - var myxml = xml; - var fpsStr = ' ' + fps + ' / ' + stage.frameRate; - myxml = StringTools.replace(xml, '_fps_', fpsStr); - myxml = StringTools.replace(myxml, '_mem_', ' ' + mem); - myxml = StringTools.replace(myxml, '_mem_max_', ' ' + mem_max); - text.htmlText = StringTools.replace(myxml, '_ms_', ' ' + (timer - ms)); - } function normalizeMem(_mem:Float):Int { return Std.int( Math.min( GRAPH_HEIGHT, Math.sqrt(Math.sqrt(_mem * 5000)) ) - 2); From 6a0b8d72776a8e77d16b8c0f17fc804d62b97774 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 10 Jun 2010 23:45:27 +0100 Subject: [PATCH 11/14] - Readme page tweaks. --- README.md | 6 ++++-- assets/stats_as.png | Bin 3408 -> 2631 bytes 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a5caa01..abc6e85 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ stats.as #### Actionscript Performance Monitor #### -![stats_as.png](http://github.com/mrdoob/stats.as/raw/master/assets/stats_as.png) +[![Flattr this](http://api.flattr.com/button/button-compact-static-100x17.png)](http://flattr.com/thing/20491/stats-as) This class provides a simple info box that will help you monitor your code performance. @@ -12,6 +12,8 @@ This class provides a simple info box that will help you monitor your code perfo * MEM Memory your code is using, if it increases per frame is VERY wrong. * MAX Maximum memory the application reached. +![stats_as.png](http://github.com/mrdoob/stats.as/raw/master/assets/stats_as.png) + ### Download ### [Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) @@ -22,4 +24,4 @@ This class provides a simple info box that will help you monitor your code perfo ### Controls ### -* **LEFT CLICK** on the top-half/bottom-half part of the panel to increase/decrease the movie FPS limit. \ No newline at end of file +* **LEFT CLICK** on the top-half/bottom-half part of the panel to increase/decrease the movie FPS limit. diff --git a/assets/stats_as.png b/assets/stats_as.png index a72cc0992fe0a5baf73aa3f7c413127c54c050a3..5a91438daa491ad630af991e086c11bdef998170 100644 GIT binary patch delta 2598 zcmV+>3fcA08pjkNiBL{Q4GJ0x0000DNk~Le0000+0001F2nGNE06R)Xxsf3~f7%8L z79AJ+n6@+k013xQL_t(|+U=TsOjK7I#($R?Ktw@{imUaDK}eNtDY$AIYqpJFtrZQG z#-eU^V~E5W7LqklY_dts>MpUitHIi>30*_Ce|6g$>)ME#jkxPa$Dp`nMT(+e`Pfky zlrJ6b{xQSMotb;@+!~?tiJ34CEw5h}CU$(4^nwlTz>$^-{-8I&&yXUjRf`Sg(+OE*teAVsx%*-B|ny%8+ zbd}7^9@)0fKi@-r{WULtVPQKR9W?>P)XW%zA=`O)`rmkCHf3ckPG4o^e@*u8O(r2B zla(t|S-G;yXNPm=_L7!1m(81}Q(k`C>EFG(h0@Zgl$K6q_wE+iw#%1WIdLMv%b%X! zkI9rle*P>D9`r9}P*Q1d(EWdl#mMBzkI2gEp|v%djT>jVu}sd2i>K4oW#qzzc-q>G zPXB@h4>@{t97m6iW5I%lf3j^?tmxvq@4SI2DVc`VYUJ@_ftHqNzhWwx(bFNFkd!qx zo0un+j4&0%rXu8vrm}sNB+rCZ- z2{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htT` zhnaOw10$Y7^TKU%Y{&{vR;pc{#5L8|goiEUOy;#KFyA;!-|)TFyjE2EEk@5@riRXn z1-rZidk3o8pfafKjr1P1N~t&}WnNes)eeCn;8TkO6U+pvq#cz(la}};avb%8lgyc^ zMZ>s{pA--;fv%?7y{TM+P|^%nXi9wK<)^EYp4CimvZl|lKWaQ%>5|&T@nr{5j!fG6 z0YI&C?i`Zv*Vl>=vXon@WN%MRBXU+ivcO_T#Tp{RJsR3oFILvat4DTP4ggDQcuO^% z)MG83IJkf0xbK`=yU!Ds%b|x*XuXSj2jf?o3~G~bhhI4Dgoa0k?Go-B$(Ny-d9Zw| z)yZ8fi;zwMWy6gMn%1_D$r{Cr3MXYRB|&_}@=Cr0sg`fUGx?g2yT=+$PXPqiselK} zguHrI2Uv%okco6Rgf9E`j!kiqWh&Rq*{T)A(=_5p-3H#_n(G4V9P__sE;NfO0lVNS;9qHLsi*{0!_9h#Wzl3 z+t3i0vF88pD3GE43KN2e{1m@J<<)s$|B9#W$xjO4DKR@cy66#Nr6^$`krBG?M>?e~ z`e`DiB{~+|qQByWAcW*e$g|GfJ~Msi*acxiotOw&9d-MIgjh->DoEfAUPv7g|6f|v z)6bLAY}6?Mg%i&;!z- zt-(}@1)0WMK2eVn^ZJXgfMApl)H7YnVE>+kkR9ti&JO`LzE*wVz;*I&YW=M6#478JtvBPR{ z3#|aE^++j7a^vRTixXT0Rsj?p`nrVf%eH@JfT zAa&kBjYX28tsalQsAI&Ins}I|T7n_J<1An@gS?Fw1%vo?QL6AAHT9{KPINZ-yCFaF zPW>mL|MLbOsGe_xb=Y5St)By#-juK2;ykGT-#q;veN$yFZ~Gl1`GjmAG Date: Thu, 10 Jun 2010 23:57:25 +0100 Subject: [PATCH 12/14] - Readme page tweaks --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7a82ffa..0c350a5 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ This class provides a simple info box that will help you monitor your code perfo * MEM Memory your code is using, if it increases per frame is VERY wrong. * MAX Maximum memory the application reached. +### Screenshot ### + ![stats_as.png](http://github.com/mrdoob/stats.as/raw/master/assets/stats_as.png) ### Download ### From 0cfc44404133d37757889736c66fbdc1ae7692ac Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Thu, 10 Jun 2010 23:59:56 +0100 Subject: [PATCH 13/14] - More tweaks --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0c350a5..f1539b2 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ stats.as This class provides a simple info box that will help you monitor your code performance. -* FPS Frames per second, how many frames were rendered in 1 second. The higher the number, the better. -* MS Milliseconds needed to render a frame. The lower number, the better. -* MEM Memory your code is using, if it increases per frame is VERY wrong. -* MAX Maximum memory the application reached. +* **FPS** Frames per second, how many frames were rendered in 1 second. The higher the number the better. +* **MS** Milliseconds needed to render a frame. The lower the number the better. +* **MEM** Memory your code is using, if it increases per frame is VERY wrong. +* **MAX** Maximum memory the application reached. ### Screenshot ### From 68aa7995fcf2d30f3ee8e7a06619e2ee84ae9806 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Fri, 11 Jun 2010 00:06:43 +0100 Subject: [PATCH 14/14] - Changed README file layout. --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f1539b2..1ffd1b1 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,15 @@ This class provides a simple info box that will help you monitor your code perfo ![stats_as.png](http://github.com/mrdoob/stats.as/raw/master/assets/stats_as.png) -### Download ### - -[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) -[Stats.hx](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.hx) (Ported by [David Wilhelm](http://github.com/bigfish)) - -### How to use ### +### Usage ### addChild( new Stats() ); ### Controls ### -* **LEFT CLICK** on the top-half/bottom-half part of the panel to increase/decrease the movie FPS limit. +* **CLICK** Top-half / bottom-half part of the panel to increase/decrease the FPS of the application. + +### Download ### + +[Stats.as](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.as) +[Stats.hx](http://github.com/mrdoob/stats.as/raw/master/src/net/hires/debug/Stats.hx) (Ported by [David Wilhelm](http://github.com/bigfish))