Re: Using both 'Benchmark' and 'strict'

2002-06-03 Thread Ron Grabowski

> Is there a simpler way ?

---
use strict;
use Benchmark;

timethese (-1, {
one => 'my @one = (1..10);
my @two = (11..20);
scalar(@one);',
two => 'my @one = (1..10);
my @two = (11..20);
scalar(@two), "\n";'
});
---

Benchmark: running one, two, each for at least 1 CPU seconds...
   one:  1 wallclock secs ( 1.05 usr +  0.00 sys =  1.05 CPU) @
191443.39/s
(n=201207)
   two:  1 wallclock secs ( 1.06 usr +  0.00 sys =  1.06 CPU) @
190574.39/s
(n=202390)
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Using both 'Benchmark' and 'strict'

2002-06-03 Thread Sisyphus

Hi,
Seems that if you 'use strict' (or even simply declare with 'my') then none
of the variables can be accessed by a Benchmark test.

To illustrate:
#! perl -w
use strict;
use Benchmark;

my @one = (1..10);
my @two = (11..20);

timethese (5, {
'one' => 'print scalar(@one), "\n";',
'two' => 'print scalar(@two), "\n";',
});

This produces:
Benchmark: timing 5 iterations of one, two...
0
0
0
0
0
   one:  0 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
(warning: too few iterations for a reliable count)
0
0
0
0
0
   two:  0 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
(warning: too few iterations for a reliable count)

To obtain the "correct" output (where the columns of '0's are replaced by
columns of '10's) I need to firstly delete 'use strict' and secondly delete
both occurrences of 'my'.
That's a rather tedious fix, and can also involve renaming of variables.

Is there a simpler way ?

Not much point in doing a benchmark if it thinks that every scalar and every
array is empty ... though it does often produce pleasingly quick timings
:-)

Cheers,
Rob


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs