# Object#send takes 10 seconds to complete

**URL:** <https://www.ruby-forum.com/t/object-send-takes-10-seconds-to-complete/181744>\
**Category:** Rails\
**Created:** [January 17, 2010, 6:10pm UTC](https://www.ruby-forum.com/t/object-send-takes-10-seconds-to-complete/181744 "2010-01-17T18:10:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![roallen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/3e96dc/32.png) [@roallen](https://www.ruby-forum.com/u/roallen)\
**Post date:** [January 17, 2010, 6:10pm UTC](https://www.ruby-forum.com/t/object-send-takes-10-seconds-to-complete/181744/1 "2010-01-17T18:10:27Z")

</div>

My rails app has over 400 models and close to 2000 methods. I call  
Object#send in one of them and in production it takes a 10-12 seconds  
for that call to complete. In development where config.cache\_classes =  
false, the same call returns in less than a second. If I set  
config.cache\_classes = true in development, I see the same 10 second  
lag. I tried using method/call and eval, but got similar response  
times.

Does send() and its ilk do some sort of lookup or scan of all the  
methods to determine if the one I’m calling is defined? Should that  
take 10 seconds to cover 2000 model methods?

Is there some alternative to dynamically call an object’s method that  
would avoid this issue? I’d prefer to bypass any checks and just invoke  
the method.

Note that the method I’m calling is not dynamically created…it exists  
in the model. I just need to call it dynamically (I don’t know which  
method to call until the code executes).

---

<div class="post-metadata">

**Author:** ![roallen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/3e96dc/32.png) [@roallen](https://www.ruby-forum.com/u/roallen)\
**Post date:** [January 17, 2010, 11:42pm UTC](https://www.ruby-forum.com/t/object-send-takes-10-seconds-to-complete/181744/2 "2010-01-17T23:42:29Z")

</div>

Robbie,  
[http://www.khelll.com/blog/ruby/ruby-dynamic-method-calling/](http://www.khelll.com/blog/ruby/ruby-dynamic-method-calling/) mentions  
a few different ways to call a method dynamically, and  
[Ruby Dynamic Method Invocation Performance](http://lojic.com/blog/2008/12/22/ruby-dynamic-method-invocation-performance/)  
talks about performance. I’d try instantiating the method and then  
calling it, see what happens there. Can’t really offer any inside  
knowledge, though, sorry.

Liam
