in reply to Unfortunately benchmarking things with $& isn't easy...
in thread Obtaining server name from UNC path
The reasonable small difference is what I expect. $& isn't as costly as it used to be, and since the blackadder code only has two regexes, you pay the price twice, compared to one for theorbtwo (due to the parens). The larger difference is that blackadder has to _copy_ the string, while that doesn't happen by theorbtwo.use warnings 'all'; use strict; use Benchmark 'cmpthese'; $::unc = '\\\\server_name\\sys_share'; cmpthese -5 => { blackadder => 'my $tmp = $::unc; $tmp =~ s/^\W*\w+//; $server = $&; $server =~ s/^\W+//;', theorbtwo => '$::unc =~ m/^\\\\\\\\([^\\\\]+)\\\\/; # Urgle. my $server = $1;', }; __END__ Name "main::unc" used only once: possible typo at bench line 6. Benchmark: running blackadder, theorbtwo for at least 5 CPU seconds... blackadder: 5 wallclock secs ( 5.08 usr + 0.00 sys = 5.08 CPU) @ 76 +238.39/s (n=387291) theorbtwo: 6 wallclock secs ( 5.07 usr + 0.00 sys = 5.07 CPU) @ 97 +024.65/s (n=491915) Rate blackadder theorbtwo blackadder 76238/s -- -21% theorbtwo 97025/s 27% --
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Unfortunately benchmarking things with $& isn't easy...
by demerphq (Chancellor) on Aug 08, 2002 at 12:42 UTC | |
by Abigail-II (Bishop) on Aug 08, 2002 at 13:37 UTC | |
by demerphq (Chancellor) on Aug 08, 2002 at 14:48 UTC | |
by Abigail-II (Bishop) on Aug 08, 2002 at 16:04 UTC |