相关疑难解决方法(0)

评论会影响Perl的性能吗?

我正在优化一些经常运行的Perl代码(每个文件每天一次).

评论是否会降低Perl脚本的速度?我的实验倾向于否:

use Benchmark;
timethese(20000000, {
    'comments' => '$b=1;
# comment  ... (100 times)
', 'nocomments' => '$b=1;'});
Run Code Online (Sandbox Code Playgroud)

提供几乎相同的值(除了噪音).

Benchmark: timing 10000000 iterations of comments, nocomments...
  comments:  1 wallclock secs ( 0.53 usr +  0.00 sys =  0.53 CPU) @ 18832391.71/s (n=10000000)
nocomments:  0 wallclock secs ( 0.44 usr +  0.00 sys =  0.44 CPU) @ 22935779.82/s (n=10000000)

Benchmark: timing 20000000 iterations of comments, nocomments...
  comments:  0 wallclock secs ( 0.86 usr + -0.01 sys =  0.84 CPU) @ 23696682.46/s …
Run Code Online (Sandbox Code Playgroud)

perl performance comments

7
推荐指数
4
解决办法
1715
查看次数

标签 统计

comments ×1

performance ×1

perl ×1