0

I was wondering if there is a way to measure a given bytecode (class file , that has main function in the original code) runtime using java bytecode instrumentation of asm.

The measure should be as accurate as possible , and if possible in nanoseconds.

Thanks

RanZilber
  • 1,840
  • 4
  • 31
  • 42
  • May I ask what do you need it for? – khachik Dec 10 '10 at 16:50
  • Yea , I'm working on a project that gets a given bytecode and does some analysis over it .The main goal is to trace accesses to object over time , and to represent it on a heat map. The reason in asking for nanotime , is because it looks much more better on the heat map, the resolution is better , and you can actully look on some "phases" of the program. – RanZilber Dec 10 '10 at 16:56

1 Answers1

1

Be warned that adding System.nanoTime() or the like will add 300 nano-seconds or more to the section of code measured.

It is possible in ASM, but I suspect won't give you the results you want.

Have you tried doing a performance test of the method. i.e. calling it for 2 seconds to see what the average call time was. This can be accurate/stable to a nano-second if you call it long enough.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • Well , since i dont have any bound on the input. It can be any program , even a one that run an hour . I want to get that time in one run . I want to intrument a line in the start of code that will mesaure the time at begging , and on at the end. Is it possible? – RanZilber Dec 10 '10 at 17:04
  • It sounds like the sort of thing a profile does quite well. Have you tried profiling the application first? – Peter Lawrey Dec 10 '10 at 18:25
  • cpu profiling can tell you things such as how many time any method is called or how long is spent in each method. VisualVM is a free profiler, but I prefer YourKit (not free) – Peter Lawrey Dec 10 '10 at 21:09