dmertz / free.fr (denis) wrote in message news:<4d8bbb4a.0405250359.90392a1 / posting.google.com>...

> Nice that we are now faster than python, but there is still room for
> small improvements.
> You can find my version here: 
> http://flwrpwr.free.fr/Ruby/bench/bench27.rb

Thanks for taking a careful look at what could be done.

> * precompile  the isHeldOrSuspended? expression  (this gives the
> largest speed gain)

If we convert those boolean conditions to a table lookup then we
should do the same in the other language implementations - so although
it's a nice optimization I haven't used it.

(You'll probably notice there are still a couple of "mistakes" where
code could be simplified - the same mistakes exist in the other
language implementations, so they'll have to wait until I feel like
changing all the implementations.)

> * use   
>    @state |= x 
> instead of 
>    @state = @state | x   
Good catch.

> * rewrite some conditionals in a more rubyish way (and more efficient)
zero? Good.

> * make better use of conditionals return value (eg like in Tcb.run)
I understand we could do that, it doesn't seem as readable to me so I
wouldn't.

> * use symbols to represent packet kind. (this is more a style change,
> speed is unchanged)

> * in WorkerTask.run, use collect! to change the content of packet.a2
Thanks, a newbie like me would never have found that.

> The speed gain between my version and #26 is approximatelly the same
> as between #26 and #25.

The more limited changes I've taken from your example make #28 ~0.7s
faster.