# Performance characteristics of Ruby constructs

**URL:** <https://www.ruby-forum.com/t/performance-characteristics-of-ruby-constructs/95150>\
**Category:** Ruby\
**Created:** [May 23, 2006, 8:11am UTC](https://www.ruby-forum.com/t/performance-characteristics-of-ruby-constructs/95150 "2006-05-23T08:11:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ola\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/858c86/32.png) [@Ola\_B](https://www.ruby-forum.com/u/Ola_B)\
**Post date:** [May 23, 2006, 8:11am UTC](https://www.ruby-forum.com/t/performance-characteristics-of-ruby-constructs/95150/1 "2006-05-23T08:11:38Z")

</div>

Hi.

I’m right in the situation where I would like to find out some  
performance characteristics for various parts of Ruby, to optimize an  
application. Is there any resources available for this?

To make it concrete, let’s take two examples.

I’ve recently written a hybrid state-based, table-driven LL(1) parser,  
where I gather productions (in the form of symbols) on a stack, and then  
execute these with send(), until a get back the next terminal. This  
works really great, but right now I’m wondering how cheap send() is,  
compared to using a real table-driven approach.

Next example: there’s fairly heave use of Class#=== throughout the  
application, and the profiler says I spend much time there. It’s a  
fairly small class of Class comparisons I’m doing, though, so maybe it  
would get me better performance by polluting the global namespace like  
this:  
class Object  
def \_\_is\_directive\_token?; false; end  
def \_\_is\_sequence\_start\_token?; false; end  
end  
class Token  
end  
class DirectiveToken  
def \_\_is\_directive\_token?; true; end  
end  
and just do tok.\_\_is\_directive\_token? instead of DirectiveToken === tok.

Any thoughts in this? Is there any place to find general information  
this, or I’m out in the wild right now?

Regards  
Ola B.
