Test a speed test script. I don't know where the error is.
/* = Create a data file that will be transmitted to the user = */$ fp = fopen ("cs.txt", "w"); for ($ I = 0; $ I <1704000; $ I ++) {fwrite ($ fp, "bandwidthkh") ;}fclose ($ fp ); // = write the current network speed calculation script = function microtime_float () {list ($ usec, $ sec) = explode ("", microtime ()); return (float) $ usec + (float) $ sec) ;}$ data = file_get_contents ("cs.txt"); $ start = microtime_float (); $ fsize = filesize ("cs.txt")/1024; // filesize returns the number of bytes of the file size echo "sent to the client ". $ fsize. "KB data
"; Echo"
"; $ Stop = microtime_float (); $ duration = ($ stop-$ start); echo $ duration." s
"; $ Speed = round ($ fsize/$ duration, 2); echo" Your network speed: $ speed KB/sec ";
The result is
It reaches 1 GB per second. isn't that possible?
Reply to discussion (solution)
Yes!
What you test is
$ Fsize = filesize ("cs.txt")/1024; // filesize returns the number of bytes of the file size.
Echo "send to client". $ fsize. "KB data
";
Echo" ";
The speed at which these three statements are executed is irrelevant to the speed of the network.
Microtime (true) is the float type of seconds.
No need to write the microtime_float function
In the past, when I used ajax to upload files, several GB of files were uploaded in a few seconds. Therefore, I think it is normal to use a local computer as both a server and a client.
Yes!
What you test is
$ Fsize = filesize ("cs.txt")/1024; // filesize returns the number of bytes of the file size.
Echo "send to client". $ fsize. "KB data
";
Echo" ";
The speed at which these three statements are executed is irrelevant to the speed of the network.
Why?