From 2fc24e16d0c83761b76af822eef34c05746c678d Mon Sep 17 00:00:00 2001 From: Ian Harrigan Date: Sat, 16 Jul 2016 16:31:29 +0200 Subject: [PATCH] Fix .gitignore and remove uneeded import --- .gitignore | 2 -- haxe/ui/core/Component.hx | 1 - haxe/ui/debug/DebugCounter.hx | 52 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 haxe/ui/debug/DebugCounter.hx diff --git a/.gitignore b/.gitignore index f0d14c28f..8fa8ea1d6 100644 --- a/.gitignore +++ b/.gitignore @@ -42,8 +42,6 @@ local.properties *.sln.docstates # Build results -[Dd]ebug/ -[Rr]elease/ *_i.c *_p.c *.ilk diff --git a/haxe/ui/core/Component.hx b/haxe/ui/core/Component.hx index d606cce6e..bc6fc2305 100644 --- a/haxe/ui/core/Component.hx +++ b/haxe/ui/core/Component.hx @@ -1,7 +1,6 @@ package haxe.ui.core; import haxe.ui.core.Component.DeferredBindingInfo; -import haxe.ui.debug.DebugCounter; import haxe.ui.layouts.DefaultLayout; import haxe.ui.layouts.DelegateLayout; import haxe.ui.layouts.Layout; diff --git a/haxe/ui/debug/DebugCounter.hx b/haxe/ui/debug/DebugCounter.hx new file mode 100644 index 000000000..aaaf0fb5c --- /dev/null +++ b/haxe/ui/debug/DebugCounter.hx @@ -0,0 +1,52 @@ +package haxe.ui.debug; + +import haxe.ui.core.Component; +import haxe.ui.util.CallStackHelper; + +class DebugCounter { + public var name:String; + private var _counters:Map = new Map(); + private var _stacks:Map = new Map(); + + public function new(name:String = null) { + this.name = name; + } + + public function incrementComponent(component:Component, fn:String = null, by:Int = 1) { + var key:String = buildComponentKey(component); + if (fn != null) { + key += '::${fn}'; + } + if (_counters.exists(key) == false) { + _counters.set(key, 0); + } + _counters.set(key, _counters.get(key) + by); + + var stack:String = CallStackHelper.getCallStackString(); + CallStackHelper.traceCallStack(); + if (_stacks.exists(stack) == false) { + _stacks.set(stack, 0); + } + _stacks.set(stack, _stacks.get(stack) + 1); + } + + public function list() { + trace("--------------------------------------------------------------------------------"); + var total:Int = 0; + for (key in _counters.keys()) { + trace('${key} - ${_counters.get(key)}'); + total += _counters.get(key); + } + trace('total: ${total}'); + trace("--------------------------------------------------------------------------------"); + for (stack in _stacks.keys()) { + trace(stack); + trace("STACK COUNT: " + _stacks.get(stack)); + trace("--------------------------------------------------------------------------------"); + } + } + + private function buildComponentKey(component:Component):String { + return '${component}#${component.id}'; + } +} \ No newline at end of file