From: "Ara.T.Howard" Date: 2005-07-16T07:35:22+09:00 Subject: Re: [QUIZ] Sampling (#39) On Sat, 16 Jul 2005, Ezra Zygmuntowicz wrote: > 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. wow. you are right there. i thought for sure doing a single io call (puts array) would be faster. i know ruby buffers, but i thought the function calls alone would kill you doing many puts. cheers. -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 ===============================================================================