Snoopy性能测试、速度测试

之前测试了curl, file_get_contents和fsockopen方法获取网页的速度,今天再测试下Snoopy,Snoopy底层还是使用fsockopen方法驱动的。按想这个测试结果应该不会比上次测试中的fsockopen要好,但结果却相反。

测试代码:

<?php
require 'Benchmark/Iterate.php';
include "Snoopy.class.php";

function snoopy_test(){
    $snoopy = new Snoopy;

    $snoopy->fetch("http://www.google.com.hk/");
    return $snoopy->results;
}

$benchmark = new Benchmark_Iterate();
$benchmark->run(10, 'snoopy_test');
$result = $benchmark->get();
var_dump($result);

测试结果:

array (size=12)
  1 => string '0.301730' (length=8)
  2 => string '0.242408' (length=8)
  3 => string '0.306462' (length=8)
  4 => string '0.242553' (length=8)
  5 => string '0.249154' (length=8)
  6 => string '0.316298' (length=8)
  7 => string '0.250106' (length=8)
  8 => string '0.248223' (length=8)
  9 => string '0.296550' (length=8)
  10 => string '0.240236' (length=8)
  'mean' => string '0.269372' (length=8)
  'iterations' => int 10

查看上次测试结果:curl, file_get_contents和fsockopen速度比较

为了测试结果有比较性,我又运行了上次的测试代码,结果和上面文章内的结果几乎一样。

(End)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>