perl 压力测试脚本

perl 压力测试脚本,第1张

概述收到一个接收get请求的压力测试的需求, require LWP::UserAgent;##LWP是perl的http请求模块 use strict; use POSIX qw(strftime);##输出时间 use threads; ##threads~~~ my $addr = "http://192.168.244.128/"; my @threads;      sub   getDRq 收到一个接收get请求的压力测试的需求, require LWP::UserAgent;##LWP是perl的http请求模块 use strict; use POSIX qw(strftime);##输出时间 use threads; ##threads~~~ my $addr = "http://192.168.244.128/"; my @threads;      sub   getDRqureyURL()    {  my ($l,$DRqureyURL,$phoneNumber)=@_;##获取所有参数 my$ua= LWP::UserAgent->new; $ua->timeout(1);##设置timeout时间,通常是10+,这里是测试 $ua->env_proxy;##获得环境变量 my$response=$ua->get($DRqureyURL);##get if($response->is_success){ print$response->decoded_content;# or whatever :P } else{ dIE$response->status_line; } print $l.' '.$phoneNumber.' '.strftime("%Y-%m-%d %H:%M:%s\n",localtime(time)); } my $j;  my $i; open (TEST,"phonenumber.txt"); my $line ; for ($j = 0;$j < 2;$j++) { $i=0; while($i<20)    { $line = <TEST>;     if (!$line)     { print "end of file,reopen.";##最后一行为空 open (TEST,"phonenumber.txt"); $line = <TEST>; } chop($line );##排除换行符 $threads[$i]  =   threads->new(\&getDRqureyURL,  $i,  $addr,  $line);   $i++; } foreach my $thread (@threads) { $thread->join();##回收thread } } close (TEST);##关闭test句柄 总结

以上是内存溢出为你收集整理的perl 压力测试脚本全部内容,希望文章能够帮你解决perl 压力测试脚本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1284420.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存