jeet_0077 Posted April 24, 2008 Share Posted April 24, 2008 Hi All, Can some one please help me on the following: I want to have something like while any user uses my website I want to know the bandwidth of that user. Is it possible to get through PHP or Javascript. Please advice. Thanks for helping Quote Link to comment Share on other sites More sharing options...
micah1701 Posted April 24, 2008 Share Posted April 24, 2008 i suppose in javascript you could make a function that sets a var with the current time (to the millisecond) then load an image (of which you know the size) and thenuse an onload() to record the time it finished loading. with a little math you could figure out how long it takes per byte to download. Quote Link to comment Share on other sites More sharing options...
jeet_0077 Posted April 24, 2008 Author Share Posted April 24, 2008 Thanks for the idea, I made something like this. Does this make sense? <script type="text/javascript"> var began_loading = (new Date()).getTime(); function done_loading() { new Image().src = 'images/loading_test.JPG'; var end_loading; end_loading= (((new Date()).getTime() - began_loading) / 1000); alert("395 Bytes/"+end_loading+" sec"); } </script> </head> <body onload="done_loading()"> </body> Quote Link to comment Share on other sites More sharing options...
jeet_0077 Posted April 29, 2008 Author Share Posted April 29, 2008 Hi All, I have written the script with jquery to load a known size file and on request complete calculated the time difference just as loading an image as before. Till this it works fine. Now I am getting like 6.4 mb file is getting loaded between ajax request and request complete as 0.278 secs. which means the bandwidth is 6.4/0.278 = (approx) 23mbps. Is my calculation is correct. If not please advice Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.