in reply to timethese, and pushing array values
If you do use lexicals, make sure that you declare the variable in the code that you're benchmarking; otherwise Benchmark won't be able to "see" your variable, because it won't be in the correct scope.
You could use something like this:
Or whatever you're benchmarking.timethese(100, { first => sub { my @foo = qw/bar foo/; my $last = pop @foo }, second => sub { my @foo = qw/bar foo/; my $last = $foo[-1] }, });
Is that the behavior I expected? I think yes, because frankly it wouldn't make much sense for Benchmark to mess about with the @_ you're playing with; it should do as little as possible, because for example, maybe you don't *want* cleanup of your variables. This allows you to have more control over what's happening.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: timethese
by husker (Chaplain) on Jul 08, 2000 at 00:58 UTC | |
by gryng (Hermit) on Jul 08, 2000 at 10:34 UTC | |
by lhoward (Vicar) on Jul 08, 2000 at 16:59 UTC | |
by gryng (Hermit) on Jul 08, 2000 at 18:05 UTC | |
by husker (Chaplain) on Jul 11, 2000 at 19:13 UTC | |
by gryng (Hermit) on Jul 13, 2000 at 01:54 UTC |