L
Lethal Possum
Hello everyone,
I use the following code to do some benchmarking of my application:
public void go(String arg) {
if (TRACE) {
long start = System.currentTimeMillis();
try {
_impl.go(arg);
} finally {
long stop = System.currentTimeMillis();
Log.trace(_impl.getClass(), "go(String arg)", stop - start);
}
} else {
_impl.go(arg);
}
}
I was wondering what would be the most efficient way to generate the
"go(String arg)" message automatically. A solution would be to do
something like:
Throwable t = new Throwable();
StackTraceElement s = t.getStackTrace()[0];
String message = s.getMethodName();
But this strikes me as neither very elegant or efficient. And it
doesn't include the full method signature, only the method name. Maybe
someone have a better idea?
Thanks in advance for your suggestions,
Thomas
I use the following code to do some benchmarking of my application:
public void go(String arg) {
if (TRACE) {
long start = System.currentTimeMillis();
try {
_impl.go(arg);
} finally {
long stop = System.currentTimeMillis();
Log.trace(_impl.getClass(), "go(String arg)", stop - start);
}
} else {
_impl.go(arg);
}
}
I was wondering what would be the most efficient way to generate the
"go(String arg)" message automatically. A solution would be to do
something like:
Throwable t = new Throwable();
StackTraceElement s = t.getStackTrace()[0];
String message = s.getMethodName();
But this strikes me as neither very elegant or efficient. And it
doesn't include the full method signature, only the method name. Maybe
someone have a better idea?
Thanks in advance for your suggestions,
Thomas