下面是一个名为while.pl的示例代码文件。
#!/usr/bin/perl
use strict;
use warnings;
my $i=0;
while (1)
{
print "Testing $i\n" ;
$i++ ;
sleep(1);
}我已经编译了这段代码
perlcc -o compiled while.pl然后执行普通代码while.pl和编译后的代码compiled。我使用ps命令观察了内存和CPU的使用情况。
ps axo %cpu,%mem,command | grep "while\|compiled"
0.0 0.0 /usr/bin/perl ./while.pl
0.0 0.1 ./compiled所以我的问题是:
while.pl占用更多的内存?发布于 2013-03-01 19:59:09
Perl代码总是被编译的。您正在做的是预先编译它,而不是在运行时。
在运行时加载编译后的表单需要更多的内存,因为在通常加载的所有内容之上加载编译后的表单加载程序。
https://stackoverflow.com/questions/15165604
复制相似问题