有没有人知道一个模块来测试互联网连接的速度?有没有Perl模块来测试网络连接速度?
4
A
回答
8
4
#!/usr/bin/env perl
use warnings; use strict;
use 5.010;
use Time::HiRes qw(gettimeofday tv_interval);
use LWP::Simple;
use File::stat;
my %h = (
'500x500' => 505544,
'750x750' => 1118012,
'1000x1000' => 1986284,
'1500x1500' => 4468241,
'2000x2000' => 7907740,
);
my $pixel = '1000x1000';
my $url_file = 'http://speedserver/file'.$pixel.'.jpg';
my $file = 'file'.$pixel.'.jpg';
unlink $file or die $! if -e $file;
my $start = gettimeofday;
my $response = getstore($url_file, $file);
my $end = gettimeofday;
open my $fh, '>>', 'speed_test.txt' or die $!;
say $fh scalar localtime;
if (not is_success $response) {
say $fh "error occured:";
say $fh "HTTP response code = $response";
}
else {
my $size = stat($file)->size if -e $file;
$size ||= 0;
if ($size == $h{$pixel}) {
my $bit = $size * 8;
my $time = $end - $start;
my $kbps = int(($bit/$time)/1000);
say $fh "$kbps kbit/s";
say $fh "$pixel : $size";
}
else {
say $fh "error occured:";
say $fh "file_size is $size - file_size expected $h{$pixel}";
}
}
say $fh "";
close $fh;
相关问题
- 1. MeetRTC试玩没有连接到网络
- 2. Rete网络没有测试版网络?
- 3. 有没有可靠的方法来测试上传速度?
- 4. 使用TrafficStats网络连接速度
- 5. 如何检查网络连接速度
- 6. 单元测试twisted.web.client.Agent的没有网络
- 7. 模拟高速网络连接
- 8. Perl模块来检测异物网址
- 9. WiFi P2P没有连接到网络
- 10. 开发没有网络连接的GWT?
- 11. 应用程序没有网络连接
- 12. Maven安装时没有网络连接
- 13. 无法检测并处理网络连接速度缓慢(WebServices)
- 14. Python:有没有更好的方法来跳过测试模块?
- 15. 绝对没有Perl模块?
- 16. GCE实例内部网络上的网络连接速度
- 17. Silverlight中的连接速度测试
- 18. Winsock滞后,测试连接速度
- 19. 负载测试连接速度慢
- 20. 网络接口速度
- 21. 网络测试连接[Python或C]
- 22. 测试网络/ Internet连接问题
- 23. 易于测试双向网络连接
- 24. C#测试恒定的网络连接
- 25. 单元测试网络连接
- 26. 网络连接总是在手机上检测到,即使没有网络
- 27. 当没有Internet连接时检测网络漫游
- 28. 当没有网络连接时关闭进度对话框
- 29. 如何查看设备连接的wifi网络连接速度?
- 30. 没有Rails的测试模块
'$ ten'是该变量一个可怜的名字。 – 2010-04-25 14:38:16
这并不容易 - 当我试图找到好的变量名称时,它们大都长得很长。 – 2010-04-25 15:14:40
这很简单。这不是真的十美元,它是$ file_size,或类似的东西。想想它代表什么,而不是它是什么。 – 2010-04-25 22:58:15