Is there a library available for purposes of timing?
I was thinking of something like timing4j (as in log4j) solving timing "issues"
in a "generic" way, initializable, like log4j, with a properties file
(specifying "registered" calling methods, threads, class loaders, how the data
is exported, etc.).
Example:
public void myMethod(Object myArg) {
try {
Timing.start();
// my code
}
finally {
Timing.end();
}
}
Timing would then accumulate timing data for this particular method: when the
method was called and how long the execution lasted. Timing would also be able
to export so gathered data in different ways: grouped by
1. Calling method (some method that calls myMethod)
2. Calling thread from within which the clling method calls myMethod.
3. Calling thread's ClassLoader.
4. ?
Averages, deviations and other statistical sugar would also be nice.
Does anyone know of (or uses) such a library?
Oliver Wong - 25 May 2006 16:29 GMT
> Is there a library available for purposes of timing?
>
[quoted text clipped - 26 lines]
>
> Does anyone know of (or uses) such a library?
If you're planning on using the properties file to turn timing on and
off, it sounds like what you really want is a profiler. A profiler, like a
debugger, wraps around your running program and inserts code to do all of
its timing stuff. As for getting data like averages, deviations etc. that
would be a feature that some profilers provide and other profilers don't.
- Oliver
Boris Gorjan - 26 May 2006 12:45 GMT
>> Is there a library available for purposes of timing?
>>
[quoted text clipped - 36 lines]
>
> - Oliver
Profiler, yes. But...
I want to detect bottlenecks in a very large distributed web application without
profiler's overkill. Just timing particular methods (inside particular classes
inside particular VMs - not all of them) that have a potential of lasting long
for various reasons (like rmi, jdbc, smtp, etc.).
Oliver Wong - 26 May 2006 14:46 GMT
> Profiler, yes. But...
>
[quoted text clipped - 3 lines]
> potential of lasting long for various reasons (like rmi, jdbc, smtp,
> etc.).
Some profilers allow you to specify rules or filters to allow you to
specify exactly which methods it is that you want to profile. See
http://www.eclipse.org/tptp/home/documents/tutorials/profilingtool/profilingexam
ple_32.html#3_3
Some profilers allow you to switch between instrumentation mode (very
accurate, but high overhead) and sampling (less accurate, very low
overhead). See
http://www.ej-technologies.com/products/jprofiler/java-profiler-faq.html#faq2
- Oliver
Boris Gorjan - 26 May 2006 15:52 GMT
>> Profiler, yes. But...
>>
[quoted text clipped - 14 lines]
>
> - Oliver
I'll look into that. Thanks.