You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by karthi <ra...@snovabits.net> on 2013/01/25 10:36:42 UTC

How to log page on-load time & page size

Hi,

I want to log each individual pages on-load time & page size:

I used pageAttached, Detached methods like below:

void pageAttached() {
		pageLoadStartupTime = System.currentTimeMillis();	
	}
	
	void pageDetached() {
		logger.info("Info: page on-load time: "
Util.getPageOnLoadTime(pageLoadStartupTime, System.currentTimeMillis())));
	}

public static long getPageOnLoadTime(long start, long end) {
		return end-start;
	}

This gives some 300ms - 400ms, 
However in the UI the same page in browser, I checked the page on-load time
using firebug option it shows 900ms

It reveals that firebug shows the images loading, js, css & other external
calls

Can anyone tell me is there anyway to log the on-load time like firebug
timing?

Regards,
Karthi.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to log page on-load time & page size

Posted by Markus Feindler <Ma...@gmx.de>.
sorry, did not see, that the question has already been answered :)

>             
> -------- Original-Nachricht --------
> Datum: Fri, 25 Jan 2013 11:40:00 +0100
> Von: "Markus Feindler" <Ma...@gmx.de>
> An: "Tapestry users" <us...@tapestry.apache.org>
> Betreff: Re: How to log page on-load time & page size
> 
>             Hey,
> 
> I don't think this is technically possible on server side, since assets 
> are 
> retrieved via separate http requests and there is no way for tapestry to 
> determine which request belongs to what "page load".
> 
> >             
> > -------- Original-Nachricht --------
> > Datum: Fri, 25 Jan 2013 01:36:42 -0800 (PST)
> > Von: karthi <ra...@snovabits.net>
> > An: users@tapestry.apache.org
> > Betreff: How to log page on-load time & page size
> > 
> >             Hi,
> > 
> > I want to log each individual pages on-load time & page size:
> > 
> > I used pageAttached, Detached methods like below:
> > 
> > void pageAttached() {
> > 		pageLoadStartupTime = System.currentTimeMillis();	
> > 	}
> > 	
> > 	void pageDetached() {
> > 		logger.info("Info: page on-load time: "
> > Util.getPageOnLoadTime(pageLoadStartupTime, 
> > System.currentTimeMillis())));
> > 	}
> > 
> > public static long getPageOnLoadTime(long start, long end) {
> > 		return end-start;
> > 	}
> > 
> > This gives some 300ms - 400ms, 
> > However in the UI the same page in browser, I checked the page on-load 
> > time
> > using firebug option it shows 900ms
> > 
> > It reveals that firebug shows the images loading, js, css & other 
> > external
> > calls
> > 
> > Can anyone tell me is there anyway to log the on-load time like firebug
> > timing?
> > 
> > Regards,
> > Karthi.
> > 
> > 
> > 
> > --
> > View this message in context: 
> > 
> http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514.html
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> > 
>         
> 
        

Re: How to log page on-load time & page size

Posted by Markus Feindler <Ma...@gmx.de>.
Hey,

I don't think this is technically possible on server side, since assets are 
retrieved via separate http requests and there is no way for tapestry to 
determine which request belongs to what "page load".

>             
> -------- Original-Nachricht --------
> Datum: Fri, 25 Jan 2013 01:36:42 -0800 (PST)
> Von: karthi <ra...@snovabits.net>
> An: users@tapestry.apache.org
> Betreff: How to log page on-load time & page size
> 
>             Hi,
> 
> I want to log each individual pages on-load time & page size:
> 
> I used pageAttached, Detached methods like below:
> 
> void pageAttached() {
> 		pageLoadStartupTime = System.currentTimeMillis();	
> 	}
> 	
> 	void pageDetached() {
> 		logger.info("Info: page on-load time: "
> Util.getPageOnLoadTime(pageLoadStartupTime, 
> System.currentTimeMillis())));
> 	}
> 
> public static long getPageOnLoadTime(long start, long end) {
> 		return end-start;
> 	}
> 
> This gives some 300ms - 400ms, 
> However in the UI the same page in browser, I checked the page on-load 
> time
> using firebug option it shows 900ms
> 
> It reveals that firebug shows the images loading, js, css & other 
> external
> calls
> 
> Can anyone tell me is there anyway to log the on-load time like firebug
> timing?
> 
> Regards,
> Karthi.
> 
> 
> 
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
        

Re: How to log page on-load time & page size

Posted by karthi <ra...@snovabits.net>.
Many thanks for your valuable infos :-)



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719523.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to log page on-load time & page size

Posted by Howard Lewis Ship <hl...@gmail.com>.
Tapestry 5.4 now logs page construction time to the console; can't remember
if it does it at DEBUG or INFO off the top of my head.

This information can be very insightful.

You can also get the same information from the built-in PageCatalog page.

On Fri, Jan 25, 2013 at 7:17 AM, Lance Java <la...@googlemail.com>wrote:

> public class MyResponseWrapper extends
> javax.servlet.ServletResponseWrapper {
>    private int contentLength = -1;
>
>    public MyResponseWrapper(ServletResponse response) {
>       super(response);
>    }
>
>    public void setContentLength(int cl) {
>       super.setContentLength(cl);
>       this.contentLength = cl;
>    }
>
>    public int getContentLength() {
>       return contentLength;
>    }
> }
>
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719536.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

Re: How to log page on-load time & page size

Posted by Lance Java <la...@googlemail.com>.
public class MyResponseWrapper extends javax.servlet.ServletResponseWrapper {
   private int contentLength = -1;

   public MyResponseWrapper(ServletResponse response) {
      super(response);
   }

   public void setContentLength(int cl) {
      super.setContentLength(cl);
      this.contentLength = cl;
   }

   public int getContentLength() {
      return contentLength;
   }
}

   



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719536.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to log page on-load time & page size

Posted by karthi <ra...@snovabits.net>.
Sorry, could not understand? how to set content length in my handler?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719531.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to log page on-load time & page size

Posted by Lance Java <la...@googlemail.com>.
Download the tapestry source and look how the GZIPFilter is contributed. You
will need to create your own
org.apache.tapestry5.services.HttpServletRequestFilter and contribute it
"before:GZIPFilter".

Perhaps you won't need to wrap the OutputStream. I *think* that tapestry is
nice enough to set the contentLength for every response. You will need to
write a response wrapper to provide a getter for the content length (since
there is not a getter in the servlet API).

public class LoggingFilter implements HttpServletRequestFilter
{
    public boolean service(HttpServletRequest request, HttpServletResponse
response, HttpServletRequestHandler handler)
            throws IOException
    {
        MyResponseWrapper responseWrapper = new MyResponseWrapper(response);
        boolean handeled = handler.service(request, responseWrapper);
        System.out.println(responseWrapper.getContentLength());
        return handeled;
    }
} 



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719530.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to log page on-load time & page size

Posted by karthi <ra...@snovabits.net>.
Could you give some example to log response size using OutputStream?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719529.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to log page on-load time & page size

Posted by Lance Java <la...@googlemail.com>.
If you really want to know how long a page takes to load in a browser, you
could use a tool like selenium [1]. 

If you want to log from the server, you might find that your servlet
container (tomcat/jetty) has a built in option for logging this info.

If not, this is probably best done by contributing a RequestFilter to the
RequestHandler. To log the response size, you will need to wrap the Response
OutputStream/Writer. You'll need to make sure that your filter occurs before
all other filters (eg the GZIPFilter).

[1] http://seleniumhq.org/



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719522.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to log page on-load time & page size

Posted by karthi <ra...@snovabits.net>.
Thank you for your reply.

So we can log only the coding log time, & is the way I right to log the
on-load time in coding is right?

& can you tell me how to log page size also?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719518.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to log page on-load time & page size

Posted by Lance Java <la...@googlemail.com>.
Firebug's load-time includes things like javascript initialization and
network latency. Neither of these metrics can be measured from the server.
Keep in mind that firefox can get multiple assets in parallel and also
caches many assets.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-log-page-on-load-time-page-size-tp5719514p5719516.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org