How to get non-unique elements from an array?

P

pauldacus

Kneel before ZHOD! Lyndon is King of Speed...

user system total real
david 35.420000 0.000000 35.420000 ( 35.370000)
jeff 9.620000 0.000000 9.620000 ( 9.620000)
jegII 9.390000 0.000000 9.390000 ( 9.390000)
markvh 7.800000 0.000000 7.800000 ( 7.800000)
martin 8.680000 0.000000 8.680000 ( 8.680000)
paolo 18.510000 0.000000 18.510000 ( 18.510000)
park 11.310000 0.000000 11.310000 ( 11.310000)
paul 19.660000 0.000000 19.660000 ( 19.660000)
robert 19.990000 0.000000 19.990000 ( 19.990000)
samk1 11.760000 0.000000 11.760000 ( 11.760000)
samk2 28.500000 0.000000 28.500000 ( 28.500000)
simonk 8.130000 0.000000 8.130000 ( 8.130000)
simons 14.010000 0.000000 14.010000 ( 14.010000)
zach 1.590000 0.000000 1.590000 ( 1.590000)
paul2 1.320000 0.000000 1.320000 ( 1.320000)
paul2a 1.370000 0.000000 1.370000 ( 1.370000)
Sylv 1.430000 0.000000 1.430000 ( 1.430000)
Sylv 1.430000 0.000000 1.430000 ( 1.430000)
Sylv 1.430000 0.000000 1.430000 ( 1.430000)
Lyndon 0.270000 0.000000 0.270000 ( 0.270000)
user system total real
david 206.300000 0.000000 206.300000 (206.300000)
jeff 0.710000 0.000000 0.710000 ( 0.710000)
jegII 0.060000 0.000000 0.060000 ( 0.060000)
markvh 10.820000 0.000000 10.820000 ( 10.820000)
martin 0.060000 0.000000 0.060000 ( 0.060000)
paolo 0.160000 0.000000 0.160000 ( 0.160000)
park 0.170000 0.000000 0.170000 ( 0.170000)
paul 0.270000 0.000000 0.270000 ( 0.270000)
robert 0.160000 0.000000 0.160000 ( 0.160000)
samk1 0.170000 0.000000 0.170000 ( 0.170000)
samk2 79.640000 0.000000 79.640000 ( 79.640000)
simonk 21.590000 0.000000 21.590000 ( 21.590000)
simons 10.600000 0.000000 10.600000 ( 10.600000)
zach 10.870000 0.000000 10.870000 ( 10.870000)
paul2 0.000000 0.000000 0.000000 ( 0.000000)
paul2a 0.000000 0.000000 0.000000 ( 0.000000)
Sylv 0.000000 0.000000 0.000000 ( 0.000000)
Sylv 0.000000 0.000000 0.000000 ( 0.000000)
Sylv 0.000000 0.000000 0.000000 ( 0.000000)
Lyndon 0.000000 0.000000 0.000000 ( 0.000000)

Lyndon 0.27
paul2 1.32
paul2a 1.37
Sylv 1.43
Sylv 1.43
Sylv 1.43
martin 8.74
jegII 9.45
jeff 10.33
park 11.48
samk1 11.93
zach 12.46
markvh 18.62
paolo 18.67
paul 19.93
robert 20.15
simons 24.61
simonk 29.72
samk2 108.14
david 241.67
 
P

pauldacus

Sorry David :) But remember: Yours was slow, but at least it worked!
Mine was slow, and didn't even work right....

I would NEVER dispute the authority of 'benchmark' but running Lyndons
vs mine, and even Sylv's scripts (on the bash command line), shows it
to be consistently quite a bit slower (10X slower) on a 10,000 element
array, w/ 2,000 dup's. What's up with that? I think on the big array,
I got a 'thin' Zero... Lyndon got a 'fat' Zero!
 
P

pauldacus

Ruby DOES kick butt!

I'm still wondering why benchmark shows such a different result from
what I'm finding by running Sylv', Lyndon's & my solution from the
command line, with 110,000 element arrays, with 20,000 dup's.

Mine comes in at 0.24 sec, Sylv's @ 0.45 sec, and Lyndon's at 12.95
sec, and these are all very consistent, w/in +- 0.01 sec. These are
WAY off of benchmark tests, which shows Lyndon's script just killing
all others....

What I'd like to see is if Perl is faster than Ruby at this job... I
have a friend who says it is cuz Perl is more 'seasoned' and is
optimized like crazy. Curious about that, and this thread just cuz
array & string processing seem to be half the body of most of my
scripts, and doing what is fast is important... not that I'd switch to
Perl. I started a Ruby script a few days ago to use 'zlib' to
recusively zip up files, and it was dead slow due to some very
inefficient array processing on my part. The thing took over a day to
run. This thread has been awesome....
 
E

ES

Ruby DOES kick butt!

I'm still wondering why benchmark shows such a different result from
what I'm finding by running Sylv', Lyndon's & my solution from the
command line, with 110,000 element arrays, with 20,000 dup's.

Mine comes in at 0.24 sec, Sylv's @ 0.45 sec, and Lyndon's at 12.95
sec, and these are all very consistent, w/in +- 0.01 sec. These are
WAY off of benchmark tests, which shows Lyndon's script just killing
all others....

What I'd like to see is if Perl is faster than Ruby at this job... I
have a friend who says it is cuz Perl is more 'seasoned' and is
optimized like crazy. Curious about that, and this thread just cuz
array & string processing seem to be half the body of most of my
scripts, and doing what is fast is important... not that I'd switch to
Perl. I started a Ruby script a few days ago to use 'zlib' to
recusively zip up files, and it was dead slow due to some very
inefficient array processing on my part. The thing took over a day to
run. This thread has been awesome....

Absolutely! The algorithm is very important and often it is the case
that you can change a too-slow algorithm out before resorting to more
drastic measures.

E
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,165
Latest member
JavierBrak
Top