[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: [QUIZ] FasterGenerator (#66

Ross Bamford

2/12/2006 6:51:00 AM

On Sun, 2006-02-12 at 14:24 +0900, Jacob Fugal wrote:
> On 2/10/06, Ruby Quiz <james@grayproductions.net> wrote:
> > This week's Ruby Quiz is to write FasterGenerator, your own
> > re-implementation of Generator with an eye towards working faster.
>
> Here's the benchmark results from my own implementation: [...]

Here's mine up to now. Being greedy I made two versions, because of the
infinite block problem mentioned on list. These are with 10000 elements
(the posted code) against the old Generator (I'm going to try the new
one later on, I want to try a few more optimisations first):

### Construction ###

Rehearsal ------------------------------------------------------------------
1.8.4-2005-12-24 Generator 0.070000 0.100000 0.170000 ( 0.204462)
Basic (fast) generator 0.010000 0.000000 0.010000 ( 0.006223)
Enhanced (***********) generator 0.650000 0.050000 0.700000 ( 0.702831)
--------------------------------------------------------- total: 0.880000sec

user system total real
1.8.4-2005-12-24 Generator 0.080000 0.070000 0.150000 ( 0.146903)
Basic (fast) generator 0.010000 0.000000 0.010000 ( 0.008860)
Enhanced (***********) generator 1.050000 0.020000 1.070000 ( 1.066803)

### next() ###

Rehearsal ------------------------------------------------------------------
1.8.4-2005-12-24 Generator 4.470000 0.240000 4.710000 ( 4.754501)
Basic (fast) generator 0.060000 0.000000 0.060000 ( 0.055710)
Enhanced (***********) generator 0.120000 0.000000 0.120000 ( 0.122150)
--------------------------------------------------------- total: 4.890000sec

user system total real
1.8.4-2005-12-24 Generator 4.480000 0.090000 4.570000 ( 4.606803)
Basic (fast) generator 0.060000 0.000000 0.060000 ( 0.060831)
Enhanced (***********) generator 0.110000 0.000000 0.110000 ( 0.119554)

I don't know how this compares with James's benchmark really, these Macs
are a bloody mystery to me... :) This is on a 2Ghz P4 / 1gig RAM.

--
Ross Bamford - rosco@roscopeco.REMOVE.co.uk