Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

Timing a webpage

I am interested in timing how long it takes to download a web page, and all the graphics within it. (An entire page load) Is there a way to have Java be a wrapper, that would time this, and then write the result to a log file? So, I could say cron this to run every 6 hours, to measure response times on my server? I apologize, I am very much a beginner with java, and don't know how difficult this might be. I might be asking for a major undertaking, but am hoping it is more of a 5 - 10 liner...

Any suggestions?
0
stakor
Asked:
stakor
  • 4
  • 2
  • 2
1 Solution
 
CEHJCommented:
http://javaalmanac.com/egs/java.net/ReadFromURL.html

Just record the time before and after calling the above
0
 
stakorAuthor Commented:
First let me say that I have not yet tried it. But... It looks like it is retrieving all of the text from the html page that the server responds with, but it is important that the images also be timed. That, and the thing I didn't mention before (sorry) the images that are on the web page are themselves being served by java applets on the page it's self.

So I am thinking that this would be a wrapper that would call the page, and time the transaction. All, while inside of a browser. (My thinking being that the browser can already jump through the hoops that will be needed to download everything (other java, cookies, etc...)
0
 
colr__Commented:
Its not going to be possible to get java to automate the process of a page download in this manner (or any other language for that matter) as what you are essentially timing is the response to final view being shown.

What you can do is maintain a page that has a mixture of images and applets etc like your site that you want to manage, then use java to time how long it takes to retrieve these elements individually.

For example, for the web page:

<html>
<img src=.".." />
</html>

You would get your java program to first download the html file, then the image file and that would be your total download speed. This is how the browser do it anyway - they download the html file, then make seperate web requests for each of the elements that page contains (like images. applets etc). You would have to manually create the list of elements to donwlaod consecutively in your java code to get a true feel for the real response time.

colr__
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
stakorAuthor Commented:
That makes sense. But I wasn't kidding about the whole I'm really not that good with java thing. I'll bump the points up to 500. Do you think that you could give me a snippet, say downloading http//www.example.com/image.gif ? (With timing and a log?)
0
 
CEHJCommented:
>>say downloading http//www.example.com/image.gif ? (With timing and a log?)

What i just posted would do that

long start = System.currentTimeMillis();
// run code i posted before
long duration = System.currentTimeMillis() - start;
System.out.printf("Time taken in milliseconds to download was %d\n", duration);
0
 
colr__Commented:
Would that work for the images as well CEHJ?

colr__
0
 
CEHJCommented:
It will work for single urls. As you said, a browser parses the page for all nested urls
0
 
CEHJCommented:
:-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now