SplFixedArray测试

网友投稿 828 2022-09-01

SplFixedArray测试

SplFixedArray测试

The SplFixedArray class provides the main functionalities of array. The main differences between a SplFixedArray and a normal PHP array is that the SplFixedArray is of fixed length and allows only integers within the range as indexes. The advantage is that it allows a faster array implementation.

大概快40%。

可以使用pear的Benchmark来比较两种之间执行时间上的差别(少数据量测试,多数据量如100000也差不多,内存占用也具有优势):

mark 03 1310263548.29697000 0.000016 11.27%

mark 04 1310263548.29699600 0.000026 18.31%

require_once 'Benchmark/Timer.php';

$timer = new Benchmark_Timer();

$timer->start();

$timer->setMarker('marker 01');

$arr = new SplFixedArray(5);

$arr[0] = 'one';

$arr[1] = 'two';

$arr[2] = 'three';

$arr[3] = 'four';

$arr[4] = 'five';

$timer->setMarker('mark 02');

$arr2 = array('one','two','three','four','five');

$timer->setMarker('mark 03');

print_r($arr);

$timer->setMarker('mark 04');

print_r($arr2);

$timer->stop();

$timer->display();

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:centos 7 Linux杀毒软件 2022年7月最新杀毒工具 杀毒软件 ClamAV(Clam AntiVirus)安装clamav-0.104.2 ​​​clamav-0.105.1使用(亲测)
下一篇:php传值和传引用的区别点总结(PHP传值和传引用的区别)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~