hi,
say i have a method that want to profile it time of execute and display on the webpage with result.
so I add a before and after advice like thisCode:package com.kiwi; public interface Xservice { public Result execute(); }
since i need to store the result, i maybe introduce a instance variable, my question is :Code:package com.kiwi; public class perfomanceAdvice { public static int timeExecuted; public void getStart() { // get start time } public void getEnd() { //get end time by substract the start time } }
1) since the advice is a singleton, it will use on all the service, say my service is not singleton and use by multiple thread, will it produce inaccurate result, since make it synchronized seem like doesn't make sense. (ok, maybe approximate result is enough, but i wondering it this make sense )
2) is that any other solution for this ? my gaol is to get the "timeExecuted" for rendered in web page, should we access the directly (is that possible ?) or this solution is enough.
i have try with difference thread (10 thread with every thread get the new object prototype) instead of sharing same instance (singleton) and get the difference results.
the result produce by singleton case, result almost all same but the prototype case produce result that is quite differences. (which i think more reflect the real scenario)
my code is simply call a Thread.sleep(x second) to tes the behaviour.
what u think ?
kiwi
----
happy hacking !



Reply With Quote