I can't tell by this code alone, but does the benchmark time the entire
script that's running, or just the iterate/sort part?
i.e. is the 'rand' function timed also, and will the time difference between
generating 20 and 10,000 numbers mess up the results?
Sorry I can't test this myself, I'm at
> > of course, the results still favor sort:
> >
> > Benchmark: timing 100 iterations of for 10_000 elems, for
> 20 elems, sort
> > 10_000 elems, sort 20 elems...
> > for 10_000 elems: 7 wallclock secs ( 5.11 usr + 0.02 sys =
> 5.13 CPU) @
> > 194931.77/s (n=100)
> > for 20 elems: 8 wal
On Wed, 2002-02-13 at 13:50, Jeremy Vinding wrote:
> > >there must be a flaw in my test here:
> > >
> > >my @bob = rand for (1..20);
> > >my @joe = rand for (1..10_000);
> >
> > Those.
> >
> > my @bob = map rand, 1 .. 20;
> > my @joe = map rand, 1 .. 10_000;
> >
>
> duh... thx
> of course, th
Jeremy Vinding wrote:
> duh... thx
> of course, the results still favor sort:
>
> Benchmark: timing 100 iterations of for 10_000 elems, for 20 elems,
sort
> 10_000 elems, sort 20 elems...
> for 10_000 elems: 7 wallclock secs ( 5.11 usr + 0.02 sys = 5.13 CPU) @
> 194931.77/s (n=100)
> f
> >there must be a flaw in my test here:
> >
> >my @bob = rand for (1..20);
> >my @joe = rand for (1..10_000);
>
> Those.
>
> my @bob = map rand, 1 .. 20;
> my @joe = map rand, 1 .. 10_000;
>
duh... thx
of course, the results still favor sort:
Benchmark: timing 100 iterations of for 10_0
On Feb 13, Jeremy Vinding said:
>there must be a flaw in my test here:
>
>my @bob = rand for (1..20);
>my @joe = rand for (1..10_000);
Those.
my @bob = map rand, 1 .. 20;
my @joe = map rand, 1 .. 10_000;
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI A
there must be a flaw in my test here:
Benchmark: timing 100 iterations of for 10_000 elems, for 20 elems, sort
10_000 elems, sort 20 elems...
for 10_000 elems: 6 wallclock secs ( 4.75 usr + 0.00 sys = 4.75 CPU) @
210526.32/s (n=100)
for 20 elems: 6 wallclock secs ( 4.86 usr + 0.00
On Wed, 2002-02-13 at 10:34, [EMAIL PROTECTED] wrote:
> > "Frank" == Frank <[EMAIL PROTECTED]> writes:
>
>
> Frank> Yeah, my bad.. I shoulda tested it:
> Frank> $max=(sort{$a<=>$b}@a)[-1];
>
> Or sort descending, probably a bit faster than a literal slice:
>
> my ($max) = sort { $b <=> $a
On Wed, 2002-02-13 at 10:34, [EMAIL PROTECTED] wrote:
> > "Frank" == Frank <[EMAIL PROTECTED]> writes:
>
>
> Frank> Yeah, my bad.. I shoulda tested it:
> Frank> $max=(sort{$a<=>$b}@a)[-1];
>
> Or sort descending, probably a bit faster than a literal slice:
>
> my ($max) = sort { $b <=> $a
> "Frank" == Frank <[EMAIL PROTECTED]> writes:
Frank> Yeah, my bad.. I shoulda tested it:
Frank> $max=(sort{$a<=>$b}@a)[-1];
Or sort descending, probably a bit faster than a literal slice:
my ($max) = sort { $b <=> $a } @input;
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc
> "Jeff" == Jeff 'Japhy' Pinyan <[EMAIL PROTECTED]> writes:
Jeff> On Feb 13, Frank said:
>> $max= (sort @values)[-1];
Jeff> You're sorting ASCIIbetically. You must sort numerically:
Jeff> (sort { $a <=> $b } @values)[-1];
>> Personally, I'd prefer Japhy's method for efficiency.
Jeff> Y
On Feb 13, Frank said:
>$max= (sort @values)[-1];
You're sorting ASCIIbetically. You must sort numerically:
(sort { $a <=> $b } @values)[-1];
>Personally, I'd prefer Japhy's method for efficiency.
Yeah, me too. ;) Sorting to find a min or max is not a good move.
--
Jeff "japhy" Pinyan
On Wed, Feb 13, 2002 at 02:08:23PM +0100, Jon wrote:
> Frank wrote:
> >
> > On Wed, Feb 13, 2002 at 01:17:50PM +0100, Andrea wrote:
> > > In article <[EMAIL PROTECTED]> wrote
>"Jeff 'Japhy' Pinyan"
> > > <[EMAIL PROTECTED]>:
> > >
> > > >>I have a set of functions that give numeric results, and
On Wed, 2002-02-13 at 08:08, Jon Molin wrote:
> Frank wrote:
> >
> > On Wed, Feb 13, 2002 at 01:17:50PM +0100, Andrea wrote:
> > > In article <[EMAIL PROTECTED]> wrote
>"Jeff 'Japhy' Pinyan"
> > > <[EMAIL PROTECTED]>:
> > >
> > > >>I have a set of functions that give numeric results, and I need
Frank wrote:
>
> On Wed, Feb 13, 2002 at 01:17:50PM +0100, Andrea wrote:
> > In article <[EMAIL PROTECTED]> wrote
>"Jeff 'Japhy' Pinyan"
> > <[EMAIL PROTECTED]>:
> >
> > >>I have a set of functions that give numeric results, and I need to compare them
>and choose the
> > >>maximal value. Is th
On Wed, Feb 13, 2002 at 01:17:50PM +0100, Andrea wrote:
> In article <[EMAIL PROTECTED]> wrote "Jeff
>'Japhy' Pinyan"
> <[EMAIL PROTECTED]>:
>
> >>I have a set of functions that give numeric results, and I need to compare them
>and choose the
> >>maximal value. Is there any simple way of findi
In article <[EMAIL PROTECTED]> wrote "Jeff
'Japhy' Pinyan"
<[EMAIL PROTECTED]>:
>>I have a set of functions that give numeric results, and I need to compare them and
>choose the
>>maximal value. Is there any simple way of finding max?
>
> Go through them one at a time, and keep track of the l
On Feb 12, Hans Holtan said:
>I have a set of functions that give numeric results, and I need to
>compare them and choose the maximal value. Is there any simple way
>of finding max?
Go through them one at a time, and keep track of the largest value:
my $max = $values[0];
for (@values) {
18 matches
Mail list logo