Response inline

On Jan 31, 2008 2:24 PM, Johan Compagner <[EMAIL PROTECTED]> wrote:
> no you dont need the threadlocal
> WebRequestCycle is already a thread local thats only used for one request
> so in your WebRequestCycle you can have a start time. (onBeginRequest)
> and then in onEndRequest you do your calculation.
>
Thanks for the explanation.

> The problem that i see is that that time covers 2 things. 1 the request
> phase on the page of the component that is clicked on
> and the response page that could be again that same page but could also be a
> completely different one.
> So at that time you are testing 2 pages
>

I am not sure if I follow you here. What do you mean by testing two
pages? Here is how I think it works (and want it to work):

1. User clicks on component on Page1 that will result in navigating to
Page2. In this case JAMon shows:  Page2  30ms.
2. User clicks on component on Page2 that will result in a refresh
(ajax or not) of Page2. IN this case JAMon shows: Page2 30 ms.

In my understanding I measure the time it takes to handle a complete
request-respone cycle.

Lars



> johan
>
>
>
>
> On Jan 31, 2008 1:32 PM, lars vonk <[EMAIL PROTECTED]> wrote:
>
> > Hi thanks for the replies,
> >
> > Yes I want to do it per Page so I can monitor the performance per page.
> >
> > Here is how I implemented it, I am not sure if I always get the name
> > of the Page name in the implementation of onEndRequest. (Allthough
> > during tests I always got the name of the Page.)
> >
> > public class JAMonMonitoredWebRequestCycle extends WebRequestCycle {
> >
> >    static final String UNIT = "ms.";
> >
> >    private ThreadLocal<Long> startTimes = new ThreadLocal<Long>();
> >
> >    public JAMonMonitoredWebRequestCycle(WebApplication application,
> > WebRequest request, Response response) {
> >        super(application, request, response);
> >    }
> >
> >    @Override
> >    protected void onBeginRequest() {
> >        super.onBeginRequest();
> >        addStartTimeToThreadLocal();
> >    }
> >
> >    @Override
> >    protected void onEndRequest() {
> >        super.onEndRequest();
> >        calculateDurationAndAddToMonitor();
> >    }
> >
> >
> >    private void addStartTimeToThreadLocal() {
> >        startTimes.set(System.currentTimeMillis());
> >    }
> >
> >    private void calculateDurationAndAddToMonitor() {
> >        if(startTimes.get() != null) {
> >            Class<?> pageClass = null;
> >            if(getWebResponse().isAjax() && getWebRequest().getPage() !=
> > null) {
> >                pageClass = getWebRequest().getPage().getClass();
> >            } else {
> >                pageClass = getResponsePageClass();
> >            }
> >            if(pageClass != null) {
> >                MonitorFactory.add(pageClass.toString(), UNIT,
> > System.currentTimeMillis() - startTimes.get().doubleValue());
> >            }
> >            startTimes.set(null);
> >        }
> >    }
> >
> > }
> >
> >
> > I believe the Page to be rendered is not availble yet in the
> > onBeginRequest so I use MonitorFactory.add() in the onEndRequest and
> > store the startTime in a ThreadLocal. While typing this email I am
> > thinking that WebRequestCycle is statefull so I probably do need the
> > ThreadLocal right?
> >
> > Lars
> >
> > On Jan 30, 2008 8:22 PM, Eelco Hillenius <[EMAIL PROTECTED]>
> > wrote:
> > > On Jan 30, 2008 11:20 AM, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
> > > > but per page...
> > >
> > > Why don't you just answer then.
> > >
> > >
> > > Eelco
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to