Find every execution execution account in Java

I study More programming pearls (Addison-Wesley, 1988) by Bentley J., and I am stumped because I cannot find any Java tool / profiler that can tell me the number of times each statement is executed in the actual thread (link: optimization of the primary number search algorithm in Chapter 1). I tried using profilers, tried APIs, but maybe I'm looking at the wrong place. Can you guys pull out some magic trick / tool and point me in the right direction, or is it that we just can't do it in Java, since each statement may not generate exactly one machine instruction and save a counter for one the operator cannot possibly OR it is just a method of calculating the processor / call time with which we can watch and work on it.

+3
source share
2 answers

I am sure that some of the various code coverage tools, such as emma and clover, record the number of times each statement is executed because it appears in reports.

I guess they really rewrite class files at the time the phrase is compiled to insert tracking code, not sure if this suits you or not.

EDIT . Recommended unknown Cobertura can be used to record execution counters

  • Emma is open source, but apparently doesn't actually record the number of accounts
  • Clover commercial coating tool is definitely
  • Cobertura , emma,
+2

, , , , . - , , .

0

Source: https://habr.com/ru/post/1717000/


All Articles