473,761 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculating the response time of different sites

freddieMaize
85 New Member
Hi there,

I need to hit few list of sites from my application and find the response time of those site and sort them (which ever is opening first will sit at the top). I have done the same using java (server side). Now my requirement is do in the client side (AJAX possibly). I’m having two challenges. Below is what I have done so far,

Expand|Select|Wrap|Line Numbers
  1.  
  2. <script>
  3. function call()
  4. {   
  5.     var d = new Date();
  6.     var xmlHttp;
  7.                 try
  8.                 {  // Firefox, Opera 8.0+, Safari 
  9.                     xmlHttp=new XMLHttpRequest();
  10.                 }
  11.                 catch (e)
  12.                 {  // Internet Explorer  
  13.                     try
  14.                     {    
  15.                         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  
  16.                     }
  17.                     catch (e)
  18.                     {   
  19.                         try
  20.                         {     
  21.                             xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");   
  22.                         }
  23.                         catch (e)
  24.                         {    
  25.                             alert("Your browser does not support AJAX!");   
  26.                             return false;    
  27.                         } 
  28.                     } 
  29.                 }
  30.                 xmlHttp.onreadystatechange=function()
  31.                 {
  32.                     if(xmlHttp.readyState==4)
  33.                         {       
  34.                             alert(xmlHttp.responseText);
  35.                            /* if(xmlHttp.responseText != undefined);
  36.                             var res_min = d.getMinutes();
  37.                             var res_sec = d.getSeconds();
  38.                             var res_time = res_min*60+res_sec;
  39.                             alert(res_time);
  40. response_time=res_time-req_time*/                      
  41.                         }
  42.                     }                        
  43.  
  44.                         var req_min = d.getMinutes();
  45.                         var req_sec = d.getSeconds();
  46.                         var req_time = req_min*60+req_sec;
  47.                         alert(req_time);
  48.  
  49.                     var url="http://localhost:8080/";
  50.                    // url=url+"?q="+q;
  51.                     xmlHttp.open("GET",url,true);
  52.                     xmlHttp.send(); 
  53.  
  54. }
  55. </script> 
Challenge 1: I’m using “var url="http://localhost:8080/";” because I’m unable to use urls of google, yahoo or bytes here. Getting “Access Denied” error. Cross domain scripting is not possible here.

So, any clues on cross domain scripting/proxy??

Challenge 2: “if(xmlHttp.rea dyState==4)”. Inside this function I get the responseText. Now all I want is, a way to find whether the url is responding or not (getting opened or not).
Reason: only if I know whether the site is accessible, (and if yes, how long?) I can proceed (since I’m calculating the response time here… like I have mentioned on the top).

I believe I have briefed my issue as much as possible. If it’s still not complete, kindly tell me on which part should I further explain. Thank you.

fREDDIE
Sep 18 '08 #1
10 5249
acoder
16,027 Recognized Expert Moderator MVP
If you've already solved this with Java on the server-side, call that script instead passing the URL and the response should be the response time. From that, you can sort the list.
Sep 18 '08 #2
freddieMaize
85 New Member
Hi acoder,

If you've already solved this with Java on the server-side, call that script instead passing the URL and the response should be the response time. From that, you can sort the list.
:)... The thing is, I want to finish off everthing in the client side in this regards. This must no way be a concern/workof for a java class. So no java and servlet stuffs are allowed...

The reason is, calling a java/servlet class will take time which must be avoided.
I mean, the time between the jsp->java->jsp cycle can be avoided if we use Ajax. This could be effective i believe (i mean, doing on the client side).

fREDDIE
Sep 18 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
I'm not saying not to use Ajax. What I suggested was that you call the JSP page via Ajax/XmlHttp.
Sep 18 '08 #4
freddieMaize
85 New Member
I'm not saying not to use Ajax. What I suggested was that you call the JSP page via Ajax/XmlHttp.
Yeah. That is also one way of doing it. But at the end of the day when a jsp page gets compiled it is going to be a java/servlet class only right, which is want I wanted to avoid.
All I’m trying is to do is to finish of the whole stuff in a single jsp/html page. The control must not go to else where.
Sep 19 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
In that case, create a new Date object - this will default to the current date/time to the millisecond. When finished, create another one and compare the two.
Sep 19 '08 #6
freddieMaize
85 New Member
Yeah the same is what I have planned to do. Something like
Expand|Select|Wrap|Line Numbers
  1. result= response time-request time.
Okay, I ll brief it out again.

I request to open a site (using, “xmlHttp.open(" GET",url,true); ”) and I find the request time mean while. (The challenge here in this step is, I’m unable to call url’s like http://freddiemaize.wordpress.com which is a external domain. JavaScript doesn’t support cross domain scripting right?).
Sep 20 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
For that you will have to use a proxy which is basically some server-side code which makes the request and passes back the response to the client. In effect, we're back to my earlier suggestion. It is possible to make cross-domain requests if you give privileges in a specific browser, but that would only work in one browser.
Sep 20 '08 #8
priyalmehta
1 New Member
Hi fREDDIE,
you mentioned that u calculated server's response time in java... cud u tell me how to do so? i'm relatively new to java n need this urgently for my college project submission...
Oct 14 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
Hi priyal, welcome to Bytes!

I would suggest you start a new thread for your question in the Java forum.
Oct 14 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
8806
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any feedback on how I might do things differently to make it either more consice, readable, or faster. ie... are there better ways to do it in Python? It won't break any records for calculating pi, that wasn't my goal, learning Python was. But it might...
9
2247
by: Rick Cook | last post by:
I would like to do a response form on one of my sites instead of posting an e-mail address for spammers. I've taken a couple of examples from sites, but the code looks clunky and non-conformant to my inexperienced eye. Also, on the sites I've found you can get the e-mail address simply by viewing the page source. It seems to me there should be a way to hide that, but as I say I'm hardly an expert. Can anyone recommend a good site to...
3
5346
by: Miller | last post by:
Hi, Can someone tell me how to calculate MFLOPS for the following C# code (on a Pentium 4 2.0 Ghz)? for (i=0; i<n; i++) { for (j=0; j<n; j++) { for (k=0; k<n; k++)
4
2163
by: Vito DeCarlo | last post by:
Over the past week, I've been noticing that any websites (on this one particular web server) built with ASP.NET have unusually slow (5 second) response times when moving through the site. There are times when the delays dissappear, but they are existent 80% of the time. This has only started up over the past week or so and I have checked CPU usage, memory usage, etc. I've also reinstalled the 1.1 version of the .NET framework just to...
20
12604
by: Jean Johnson | last post by:
Hello - I have a start and end time that is written using the following: time.strftime("%b %d %Y %H:%M:%S") How do I calculate the elapsed time? JJ
2
2683
by: deisner | last post by:
All- I have a Framework 2.0 application running under Windows 2003 Server and IIS utilizing the default application pool. On my development machine (XP w/ IIS 5.1) the code runs perfectly. But when deployed recompiled under 2003/6.0, every time the application gets to a Response.Redirect (happens right away when a user logs in), the Session data is lost.
1
1546
by: badger_nz | last post by:
Hi all, I recently opened an account with a USA-based hosting company. I'm new to the world of hosting providers, and I have a question regarding performance that I'm hoping somebody here can answer in plain language. I have uploaded a static .html page onto my domain. The page links in two stylesheets and a few images - total page size is 65kb. I opened an
23
3231
by: mosesdinakaran | last post by:
Hi All, I need a small clarification in submitting the forms, Ur suggestions please. In a page I have two form and also two submit butons. (ie)
3
1740
by: mfaisalwarraich | last post by:
Hi everybody. I have some problem while calculating time. i have employees who are working on hourly basis. i want to calculate the time. for example if an employee start working at 11:00pm (10-November-2008) and finish his job at 8:00am (11-November-2008) then how i can calculate the time between two different dates? i used dateDiffer method but it only displays the time difference between one date. please tell me how i can do this. thank you....
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.