On Jul 15, 2005, at 3:04 PM, Ara.T.Howard wrote:

> 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
> ====================================================================== 
> =========
>
>
I get pretty much the same size of the file every time I run this.  
And if you look at the original quiz posting by James Edward Grey you  
will see that the sample run data that he said was the time to beat  
had a size of  49011436 whereas mine is 49444444. So yeah mine is a  
bit skewed higher I guess. But when I look through the results it  
looks like a nice random spread covering all the numbers in the  
limit. My solution is really very simple and almost all the time it  
takes to run is spent on IO because when I run the following:
ez$ time ruby -e'1.upto(5_000_000) {|i| puts i} ' > out

real    0m27.236s
user    0m23.802s
sys     0m0.998s

So it takes about 13 seconds for the math and 27 seconds for the IO.

Cheers-
-Ezra Zygmuntowicz
Yakima Herald-Republic
WebMaster
509-577-7732
ezra / yakima-herald.com