
#!/usr/bin/perl
use Benchmark;
timethese ( 100,
{
'local'=>q
{
for ( 1..10000 )
{
local $a=$_;
$a *= 2;
}
},
'my'=>q
{
for ( 1..10000 )
{
my $a=$_;
$a *= 2;
}
}
} );
可以拿来计算algorithm耗费多少时间.
QUOTE:
timethese ( 做几次iteration,
{
'Algorithm名稱'=>q{ 要计算时间的algorithm },
'Algorithm名稱'=>q{ 要计算时间的algorithm }
} );




by: 发表于:2017-09-12 14:54:13 顶(0) | 踩(0) 回复
??
回复评论