龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php 自己写的php压力测试工具

时间:2014-07-19 02:11来源:网络整理 作者:网络 点击:
分享到:
自己写的php压力测试工具 php脚本,利用文本里面的url,随机取出url来压力测试[代码片段(22行)]

php脚本,利用文本里面的url,随机取出url来压力测试

<?php
$doman = $argv[1];
$port = $argv[2];
$file = file("url.text");
$file_arr = array();
foreach($file as &$line){
        $file_arr[] = trim($line);
}
//print_r($file_arr);
$time1 = time();
for($i=0; $i<100000; $i++){
        $random = rand(0,189);
        $rand_url = 'http://'.$doman.':'.$port.$file_arr[$random];
        $content = file_get_contents($rand_url);
}

$time2 = time();

echo $time2 - $time1;
echo "\\n";
//该片段来自于http://outofmemory.cn
精彩图集

赞助商链接