Re: finding max value

2002-02-14 Thread Carl Franks
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

Re: finding max value

2002-02-13 Thread Andrea Holstein
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 largest

Re: finding max value

2002-02-13 Thread Frank
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 finding max? Don't

Re: finding max value

2002-02-13 Thread Jon Molin
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 there any simple way of

Re: finding max value

2002-02-13 Thread Chas Owens
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 to compare them and

Re: finding max value

2002-02-13 Thread Frank
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 I need to compare them

Re: finding max value

2002-02-13 Thread Jeff 'japhy' Pinyan
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

Re: finding max value

2002-02-13 Thread Randal L. Schwartz
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 Yeah, me too. ;)

Re: finding max value

2002-02-13 Thread Chas Owens
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 } @input; --

Re: finding max value

2002-02-13 Thread Chas Owens
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 } @input; --

Re: finding max value

2002-02-13 Thread Randal L. Schwartz
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. - +1 503 777

RE: finding max value

2002-02-13 Thread Jeremy Vinding
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

RE: finding max value

2002-02-13 Thread Jeremy Vinding
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_000 elems, for

Re: finding max value

2002-02-13 Thread Tagore Smith
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) for 20

RE: finding max value

2002-02-13 Thread Chas Owens
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, the results still favor

RE: finding max value

2002-02-13 Thread Jeff 'japhy' Pinyan
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 Acacia

RE: finding max value

2002-02-13 Thread Jeremy Vinding
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 wallclock secs (

finding max value

2002-02-12 Thread Hans Holtan
Hi everyone, 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? Hans -- Hans E. E. Holtan Graduate Student UC Berkeley-Department of Plant

Re: finding max value

2002-02-12 Thread Jeff 'japhy' Pinyan
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) {