Thanx
--
Yang
> Hi guys,
> Is it possible to know the internet speed of the visitors with php?
No. There are too many things that have to happen to try to determine
the speed of the visitor. And most of those things, PHP has no access to.
--
Randy
function microtime_diff($a, $b) {
list($a_dec, $a_sec) = explode(" ", $a);
list($b_dec, $b_sec) = explode(" ", $b);
return $b_sec - $a_sec + $b_dec - $a_dec;
}
function test_speed($test_size) {
flush();
$start_time = microtime();
$comment = "<!--O-->";
$len = strlen($comment);
for($i = 0; $i < $test_size; $i += $len) {
echo $comment;
}
flush();
$duration = microtime_diff($start_time, microtime());
if($duration != 0) {
return $test_size / $duration / 1024;
}
else {
return log(0);
}
}
$speed = test_speed(1024);
if($speed > 50) { // a fast connection, send more byte for more accuracy
$speed = test_speed(10240);
if($speed > 500) { // a really fast connection, send even more byte for
more accuracy
$speed = test_speed(102400);
}
}
echo sprintf("Download speed is %0.3f kb/s", $speed);
I have the code set up here: http://www.conradish.net/speed.php. On my cable
connection I get around 300 kb/s, which is about right.
Uzytkownik "Yang Li Ke" <yang...@sympatico.ca> napisal w wiadomosci
news:v7fOb.2709$XZ.4...@news20.bellglobal.com...
Interesting concept,
when I test your link, I average 240, but I am on 3 Mbit
when I run it localy with my test server, GigaBit from my desktop to 1
switch to server, I get 190
hmm, I think it is rather testing execution speed.
--
Mike Bradley
http://www.gzentools.com -- free online php tools
I tried adding ob_start("ob_gzhandler") to the beginning of the file. The
measured speed increased nearly ten-fold. So I don't think it's testing the
execution speed.
Uzytkownik "CountScubula" <m...@scantek.hotmail.com> napisal w wiadomosci
news:UzmOb.12266$eI6....@newssvr25.news.prodigy.com...
Hmm, here is an idea, havent done any code, I am going to sleep, diving in
the morning.
what if you were to send a header with a timestamp:
fist call to page:
Location:
http://www.blablabla.com/test.php?action=loop&step=1&ts[1]=microtime
next call to page
Location:
http://www.blablabla.com/test.php?action=loop&step=2&ts[1]=microtime&ts[2]=m
icrotime
loop a couple times of times, average out the time stamps for an average
page redirct.
this will be used a reference to delays, overhead etc...
then do this header
Location: http://www.blablabla.com/test.php?action=headers&avg=_avg_stamp
then for that page, send a lot of header data:
for ($i=0; $i < 100; $i++)
{
$head = "X-SpeedTest: --- speed test $i---";
$headerSize += strlen($head) + 2;
header($head);
}
header("Location:
http://www.blablabla.com/test.php?action=done&avg=avg_stamp&ts=mictotime&ds=
$headerSize
then the last call to the page:
$timeElapsed = (microtime() - $_GET['ts']) - $_GET['avg'];
$dataSize = $_GET['ds'];
hmm, then I think we would have a size of data sent, and time to send?
just a thought.....What do you think?
<SNIP>
define('MAX_ATTEMPT',1);
$addr = $_SERVER['REMOTE_ADDR'];
$string = trim(exec("ping $addr -n ".MAX_ATTEMPT));
$pingtime = array();
if(!empty($string))
{
$pingtime = preg_split('/[\s=]+/',$string);
print_r($pingtime);
}
</SNIP>
We can even send a fixed buffer size using (-l size) option.
--
Rahul Anand
you can test it here:
http://www.gzentools.com/test/speed.php
and the source is here:
http://www-3.gzentools.com/snippetview.php?c=Concepts&v=speedtest.php
--
Mike Bradley
http://www.gzentools.com -- free online php tools
"CountScubula" <m...@scantek.hotmail.com> wrote in message
news:ZxrOb.12331$0s1....@newssvr25.news.prodigy.com...
Tried your page. It's reporting that my 3 mbit connection is capable of
downloading 1.8 k per second. Perhaps a larger amount of test data is
needed?
Uzytkownik "CountScubula" <m...@scantek.hotmail.com> napisal w wiadomosci
news:ZxrOb.12331$0s1....@newssvr25.news.prodigy.com...
http://www.gzentools.com/test/speedtest.php
I think it may be off by a factor of 9 to 10, I arrive at this nubmer by
doing a local test, and it shows my DL speed as 5 Mbit/s, and when I do a
ftp download of a large file from the same server, I get about 51 Mbit/s
let me know what everyone thinks, I think we can make this happen!
--
Mike Bradley
http://www.gzentools.com -- free online php tools
"Chung Leong" <cherny...@hotmail.com> wrote in message
news:KoWdnQNVoeu...@comcast.com...
>Ok, now try it at:
>
>http://www.gzentools.com/test/speedtest.php
I get "too many" redirection errors with NN7, Mike.
"Your line speed is around 11.788 Mbit/s" for Stargate
sat modem via IE6.
-
Every day above ground is a Good Day(tm).
-----------
http://diversify.com Website Application Programming
OK, I changed the redirects to a lower number, how is it now?
btw, was 11.788 to high or too low?
http://www.gzentools.com/test/speedtest.php
>OK, I changed the redirects to a lower number, how is it now?
NN works now: Your line speed is around 933.794 Kbit/s
Your line speed is around 1.030 Mbit/s
Your line speed is around 7.401 Mbit/s
Your line speed is around 1.062 Mbit/s
IE: Your line speed is around 2.025 Mbit/s
Your line speed is around 447.926 Kbit/s
Your line speed is around 2.340 Mbit/s
Your line speed is around 754.559 Kbit/s
>btw, was 11.788 to high or too low?
Good question. Satellites connections are iffy. Sometimes it
takes half an hour to upload 40 files for a site where it
would have taken 5 minutes via my 56k modem. Sometimes I get
2MB download speeds, other times 7MB speeds. The variations
in your program are probably due to the sat latencies.
Are others with true hardwired connections getting more closely
matched results, or widely varying results like mine?
----------------------------------------------------------------
"Let's sing praise to Aphrodite || www.diversify.com
She may seem a little flighty, || Full Service Websites
but she wears a green gauze nighty, || PHP Applications
And she's good enough for me." || SQL Database Development
Hmm, I do not know, c'mon people post a little, please.
Btw, I did an ftp download localy, and tweeked script to match that. I
know, rudimentry baseline.