how can i calculate response time of website ?
1 posts in topic
Flat View  Flat View

Posted By:   sandip_shil
Posted On:   Thursday, July 26, 2007 06:19 AM

hello friends,
actually i want to calculate response time of website (what time it is taking to open on browser)onclick event with a button (link to that website url)...can anyone give some idea ...how can i solve this ....
with regards..

Re: how can i calculate response time of website ?

Posted By:   shiladitya_sircar  
Posted On:   Wednesday, September 12, 2007 01:01 AM

try {
long t = System.currentMillis();
// Create a URL for the desired page
URL url = new URL("http://hostname:80/index.html");

// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while ((str = in.readLine()) != null) {
// str is one line of text; readLine() strips the newline character(s)
} catch (MalformedURLException e) {
} catch (IOException e) {
System.out.println("The query took "+(System.currentMillis()-t)+" ms.");

Note, the above code will fetch the index.html content and unlike web browsers it will not attempt to load any MIME types etc. However, it will give you an idea of the response time of the web server. If you need to emulate browser client interaction response times you need to use a screen scraping utility and time it. A popular screen scraping utility is Selenium you can use it to code your timing test cases.

About | Sitemap | Contact