This shows you how to add profiling to your own code. Normally you will have something like this in your code (eg in MyFactory.java) to retrieve a manager object: public PersistenceManager getPersistenceManager() { return new DefaultPersistenceManager(); } To get a profiled manager object instead, use: public PersistenceManager getPersistenceManager() { return ObjectProfiler.getProfiledObject(PersistenceManager.class, new DefaultPersistenceManager()); } Note that a side effect of this is that you will no longer be able to downcast to DefaultPersistenceManager. This is probably a good coding practice anyway, but it is something to be aware of. Use our modified webwork050503-profiling.jar instead of your normal webwork.jar . Simply add these lines around the code you wish to profile. UtilTimerStack.push("some text"); //code that you want to profile UtilTimerStack.pup("some text"); // this needs to be the same text as in push()
Using the URL
Using code
UtilTimerStack.setActive(true) In your code you can check if profiling is turned on using: System.getProperty(UtilTimerStack.ACTIVATE_PROPERTY) You can also set the minimum time reported in the trace when profiling. You probably only want to profile methods that take more than 50ms, which is done like so: System.setProperty(UtilTimerStack.MIN_TIME, "50"); |