0
#test.pl

use Getopt::Long;
Getopt::Long::Configure ("bundling");

GetOptions ( 'TestB|B|b' => \$testb ,
             'TestA|A|a' => \$testa, );

这是我的情况,我可以解释perl test.pl -Ba

所以我用Getopt::Long::Configure ("bundling");

因此,即使我尝试使用选项执行,我的程序也开始变慢 perl test.pl

有没有最好的方法来解决这个问题?

基准测试结果:

with Getopt::Long::Configure ("bundling");

real    0m6.101s
user    0m2.040s
sys     0m0.260s

Without Getopt::Long::Configure ("bundling");

real    0m3.019s
user    0m2.020s
sys     0m0.200s
4

1 回答 1

1

虽然bundling显然会减慢初始处理速度(因为您现在必须为各种子字符串组合解析参数字符串),但对于空脚本,您似乎最多会增加 4% 的系统时间和 1% 的用户时间。与实际运行脚本的成本相比,这不应该是非常重要的。我承认我不确定实时变化 - 它们似乎不太相关 - 这可能是由于其他一些因素吗?

于 2010-08-27T15:39:42.067 回答