However, if you do bench it, please do post results.
#!/usr/bin/perl use warnings; use strict; { package Exported; use Time::HiRes qw{ gettimeofday }; sub foo { gettimeofday } } { package FullName; use Time::HiRes; sub foo { Time::HiRes::gettimeofday } } { package CodeRef; use Time::HiRes; *foo = *Time::HiRes::gettimeofday{CODE}; } use Test::More tests => 2; cmp_ok abs(Exported::foo() - FullName::foo()), '<', 1e-4, 'almost same +'; cmp_ok abs(Exported::foo() - CodeRef::foo()), '<', 1e-4, 'almost same +'; use Benchmark qw{ cmpthese }; cmpthese(-3, { exported => \&Exported::foo, fullname => \&FullName::foo, coderef => \&CodeRef::foo, });
On my i3 notebook:
| Rate | exported | fullname | coderef | |
| exported | 3537621/s | -- | -6% | -72% |
| fullname | 3753422/s | 6% | -- | -70% |
| coderef | 12498685/s | 253% | 233% | -- |
coderef => sub { CodeRef::foo() },
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
In reply to Re^2: Is there any (performance) benefit to importing functions?
by choroba
in thread Is there any (performance) benefit to importing functions?
by YenForYang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |