Reputation: 226
The thing I want to do is, count how many locks happened during the execution of one JVM application. (I know the lock number may change from run to run, but I just want to get the average number). And I cannot change the application, since it is one benchmark.
I have tried to use JRockit-JDK, but two problems:
The platform I am using is Ubuntu Server. Any suggestions on this would be great appreciated.
Upvotes: 1
Views: 314
Reputation: 4844
To do this previously I've used AspectJ with a pointcut that detects locking and a counter i.e.
public aspect CountLocks{
private static AtomicInteger locks = new AtomicInteger();
before(Object l) : lock() && args(l) { locks.incrementAndGet(); }
after() : execution(void main(String[])) { System.out.println(locks+" locks"); }
}
But this obviously involves weaving the code, potentially changing its performance characteristics.
Upvotes: 0