在perl中获取Epoch-Seconds(时间戳)很容易:
time
Run Code Online (Sandbox Code Playgroud)
但是什么是毫秒?最有效的方式似乎是时间*1000,但这并不像我希望的那样准确.除了记录@perldoc的长期条款之外,还有什么好的提示吗?
如何在 go 代码中获取 func 描述?
// My very nice description
func myFunc() { ... }
Run Code Online (Sandbox Code Playgroud)
我想要My very nice description.
获取 func 的名称非常简单:
runtime.FuncForPC(reflect.ValueOf(myFunc).Pointer()).Name()
Run Code Online (Sandbox Code Playgroud)
文档有类似的东西吗?我可以解析原始的 go 文件。有什么捷径吗?
我确实有以下简单的代码:
my $TimeZone = $hCache->{'TimeZone'}; # Cache gets filled earlier
my $DateTime = DateTime->now();
$DateTime->set_time_zone($TimeZone);
Run Code Online (Sandbox Code Playgroud)
这段代码运行在一个应用服务器中,它基本上是一个长时间运行的 perl 进程,它接受传入的网络连接。
这个应用程序服务器有时会变得“脏”,上面的代码打印出以下错误:
DateTime::TimeZone::new 的“name”参数(“Europe/Berlin”)是一个“glob”,它不是允许的类型之一:/srv/epages/eproot/Perl/lib/site_perl/ 处的标量linux/DateTime.pm 第 1960 行。
当我尝试调试变量“$TimeZone”时,我没有得到更多细节。
例如
print ref($TimeZone); # prints nothing (scalar?)
print $TimeZone; # prints "Europe/Berlin"
Run Code Online (Sandbox Code Playgroud)
如果我强制时区再次成为字符串,则代码有效,如下所示:
my $TimeZone = $hCache->{'TimeZone'}; # Cache gets filled earlier
my $DateTime = DateTime->now();
$DateTime->set_time_zone($TimeZone."");
Run Code Online (Sandbox Code Playgroud)
我的问题是:
我目前正在对perl程序进行微优化,并喜欢优化一些getter.
我有一个这个getter结构的包:
package Test;
our $ABC;
sub GetABC { $ABC } # exported sub...
Run Code Online (Sandbox Code Playgroud)
调用GetABC()会产生大量与子相关的开销.直接通过$ Test :: ABC访问变量的速度非常快.
有没有办法将getter别名变量来获得与我直接调用变量相同的性能提升?用"()"内联提示似乎不起作用......