Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/04/2010, 16:25
Avatar de neodani
neodani
 
Fecha de Ingreso: marzo-2007
Mensajes: 1.811
Antigüedad: 17 años, 2 meses
Puntos: 20
Conocer la velocidad de transferencia del servidor

Buenas,

¿Sabéis como puedo medir la capacidad de transferencia del servidor? es decir, la velocidad de descarga y/o de subida?

He encontrado un script pero los resultados que me muestra no son del todo convincentes. Es el siguiente:

Código PHP:
Ver original
  1. <?php
  2.  
  3. // Initialize cURL with given url
  4. $url = 'http://download.bethere.co.uk/images/61859740_3c0c5dbc30_o.jpg';
  5. $ch = curl_init($url);
  6.  
  7. curl_setopt($ch, CURLOPT_HEADER, 0);
  8. curl_setopt($ch, CURLOPT_USERAGENT, 'Sitepoint Examples (thread 581410; http://www.sitepoint.com/forums/showthread.php?t=581410)');
  9. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  10. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
  11. curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  12.  
  13.  
  14. $execute = curl_exec($ch);
  15. $info = curl_getinfo($ch);
  16.  
  17. // Time spent downloading, I think
  18. $time = $info['total_time']
  19.       - $info['namelookup_time']
  20.       - $info['connect_time']
  21.       - $info['pretransfer_time']
  22.       - $info['starttransfer_time']
  23.       - $info['redirect_time'];
  24.  
  25.  
  26. // Echo friendly messages
  27. header('Content-Type: text/plain');
  28. printf("Downloaded %d bytes in %0.2f seconds.\n", $info['size_download'], $time);
  29. printf("Which is %0.3f mbps\n", $info['size_download'] * 8 / $time / 1024 / 1024);
  30. printf("CURL said %0.3f mbps\n", $info['speed_download'] * 8 / 1024 / 1024);
  31.  
  32. echo "\n\ncurl_getinfo() said:\n", str_repeat('-', 31 + strlen($url)), "\n";
  33. foreach ($info as $label => $value)
  34. {
  35.     printf("%-30s %s\n", $label, $value);
  36. }

Y subido este script al servidor me da el siguiente resultado.

Código:
Downloaded 6576848 bytes in 10.51 seconds.
Which is 4.774 mbps
CURL said 4.576 mbps


curl_getinfo() said:
---------------------------------------------------------------------------------------------
url                            http://download.bethere.co.uk/images/61859740_3c0c5dbc30_o.jpg
content_type                   image/jpeg
http_code                      200
header_size                    263
request_size                   198
filetime                       -1
ssl_verify_result              0
redirect_count                 0
total_time                     10.965
namelookup_time                0.001
connect_time                   0.002
pretransfer_time               0.002
size_upload                    0
size_download                  6576848
speed_download                 599803
speed_upload                   0
download_content_length        6576848
upload_content_length          0
starttransfer_time             0.45
redirect_time                  0
Si un 1MB equivale a 8Mb

Downloaded 6576848 bytes in 10.51 seconds.
Which is 4.774 mbps
CURL said 4.576 mbps

Quiere decir que descargó la imagen a 4,774 / 8 = 0,596MB >> aprox. 596 KiloBytes es muy poco!!

Sabéis alguna otra de medirlo? el script falla? alguien lo puede probar y poner sus resultados?

Muchas gracias de antemano!