From: "Ara.T.Howard" Date: 2005-07-16T07:04:01+09:00 Subject: Re: [QUIZ] Sampling (#39) On Sat, 16 Jul 2005, Ezra Zygmuntowicz wrote: >> I /really/ want to know how this is possible. Multi-processor solution? >> >> >> >> > Nope This is running on a single 1.6Ghz G5 tower with about 15 other programs > running including photoshop and dreamweaver. And my solution is only 9 lines > of code ;-) Here's some more results with a little more time shaved off: > ezra:~/Sites/______raill_stuff ez$ time ./sample.rb 5_000_000 1_000_000_000 > > big_sample.txt > > real 0m39.860s > user 0m34.343s > sys 0m1.370s > ezra:~/Sites/______raill_stuff ez$ ls -l big_sample.txt > -rw-r--r-- 1 ez ez 49444444 Jul 15 14:25 big_sample.txt this means your __average__ line size is 9. that means your average number has 8 digits (ignoring newline). a uniform sampling should have an average line size of about 5 digits (6 chars counting newline). seems like a heavy bias towards the top. do other runs yield similar file sizes or is this merely chance? i was getting this kind of result by picking value in a range that ensured i'd have enough left to fufill the remainder... it tends to skew high. on a side note - on the G5 here it seems to take me 54 seconds to even write a 5,000,000 entry array full of zeros: ~ ahoward$ time ruby -e' puts(Array::new(5_000_000, 0)) ' > out real 0m54.361s user 0m53.100s sys 0m0.560s our dell 2650s give similar times... odd... -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================