Never played with it before, but from the docs it looks to me like you can have only one (global) instance. In order to use it the way you want you'd probably have to add a lot of extra code to your methods (enough to throw off the counts).
Documentation is definitely a bit sparse. On Jul 22, 10:28 am, Andrius <[email protected]> wrote: > Hi, > > I'm not sure whether I'm badly misusing InstructionCount or there is a > bug, but let's assume the first one for now... > > The simplified situation is like that: I have a function (say, foo()) > for which I want to track the number of instructions executed and the > function itself calls another function (say, bar()), for which I also > want to keep track of the number of instructions executed, something > like: > > ... > private void foo(){ > Debug.InstructionCount icount = new Debug.InstructionCount(); > icount.resetAndStart(); > // Some code here > bar(); > // Some more code > if (icount.collect()){ > // Log the number of instructions, icount.globalTotal() > } > > } > > private void bar(){ > Debug.InstructionCount icount = new Debug.InstructionCount(); > icount.resetAndStart(); > // Some code here > if (icount.collect()){ > // Log the number of instructions, icount.globalTotal() > } > > } > > Well, you get the idea. So, in a slightly more complex case (some more > function calls, but nothing very complex), what happens is: > > 07-22 15:07:36.283: DEBUG/dalvikvm(10131): +++ active profiler count > now 0 > 07-22 15:07:45.222: DEBUG/dalvikvm(10131): +++ active profiler count > now 1 > 07-22 15:07:45.242: DEBUG/dalvikvm(10131): +++ active profiler count > now 2 > 07-22 15:07:45.292: DEBUG/dalvikvm(10131): +++ active profiler count > now 1 > 07-22 15:07:45.312: DEBUG/dalvikvm(10131): +++ active profiler count > now 2 > 07-22 15:07:47.052: DEBUG/dalvikvm(10131): +++ active profiler count > now 1 > 07-22 15:07:47.082: ERROR/dalvikvm(10131): ERROR: instruction counting > not enabled > 07-22 15:07:47.082: ERROR/dalvikvm(10131): VM aborting > 07-22 15:07:47.193: INFO/DEBUG(28): *** *** *** *** *** *** *** *** > *** *** *** *** *** *** *** *** > 07-22 15:07:47.202: INFO/DEBUG(28): Build fingerprint: 'generic/sdk/ > generic/:2.1-update1/ECLAIR/35983:eng/test-keys' > 07-22 15:07:47.202: INFO/DEBUG(28): pid: 10131, tid: 10131 >>> > de.tlabs.mobileCloud.client <<< > 07-22 15:07:47.202: INFO/DEBUG(28): signal 11 (SIGSEGV), fault addr > deadd00d > ... > > I could understand that, e.g. only one counter could be running for a > thread or something, but the number of counters clearly goes up and > down for a while until DalvikVM exits. > > Any ideas on what could be wrong and/or how I could keep track of > instruction count for each single method? > > Thanks! > > Andrius -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

