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?
stakorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.