当我在看的输出杰韦利:: NYTProf V4的CGI程序 ,我碰到了前来diagnostics.pm
通过独占时间排序然后命名-在报告中源代码文件 。
首先,我不明白为什么这将是在生产代码。 我更深入地挖掘,通过该报告,并发现它被称为由main::BEGIN@17
。 这反过来,是以下行:
# spent 34µs (26+8) within main::BEGIN@15 which was called: # once (26µs+8µs) by main::RUNTIME at line 15
use strict;
# spent 34µs making 1 call to main::BEGIN@15 # spent 8µs making 1 call to strict::import
# spent 36µs (17+19) within main::BEGIN@16 which was called: # once (17µs+19µs) by main::RUNTIME at line 16
use warnings;
# spent 36µs making 1 call to main::BEGIN@16 # spent 19µs making 1 call to warnings::import
# spent 292ms (171+121) within main::BEGIN@17 which was called: # once (171ms+121ms) by main::RUNTIME at line 17
no diagnostics;
# spent 292ms making 1 call to main::BEGIN@17
# spent 135µs (27+108) within main::BEGIN@18 which was called: # once (27µs+108µs) by main::RUNTIME at line 18
use Carp qw( carp croak );
因此,这似乎是罪魁祸首。 我删除了no diagnostics
线,电话不见了,有效节省时间约300毫秒。
下面是的perldoc use
说对no
关键字:
有一个相应的不声明unimports通过采用进口的含义,即它调用unimport模块列表,而不是进口。 它的行为就如同与进口版本的省略或空列表,或没有unimport方法不被人发现。
no integer; no strict 'refs'; no warnings;
因此,这里是我的实际问题: 我在假设,如果我通话两不误no diagnostics
,它实际上是加载之前,它是unimport
版?
是调用no diagnostics
类似这样的一段代码?
BEGIN {
require diagnostics.pm;
diagnostics->unimport;
}
结果,它是一个坏主意,从未被进口的,因为实际上第一次加载它只是unimport的东西?