# Ruby-prof for WATIR testcase calls WIN32OLE#method\_missing

**URL:** <https://www.ruby-forum.com/t/ruby-prof-for-watir-testcase-calls-win32ole-method-missing/169845>\
**Category:** Ruby\
**Created:** [June 9, 2009, 3:22pm UTC](https://www.ruby-forum.com/t/ruby-prof-for-watir-testcase-calls-win32ole-method-missing/169845 "2009-06-09T15:22:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [June 9, 2009, 3:22pm UTC](https://www.ruby-forum.com/t/ruby-prof-for-watir-testcase-calls-win32ole-method-missing/169845/1 "2009-06-09T15:22:48Z")

</div>

Hi all,

I generated ruby profile for my test suite. In my profile i observed  
that 10% of my test time is taken by WIN32OLE#method\_missing. It was  
called 60077 times.

Can anyone please help me understand when and why it is getting called.  
Is there any way to optimize it ?

I’m using  
ruby 1.8.4  
watir 1.5.1.1192  
ruby-prof 0.7.3

I’m attaching my generated ruby graph profile.

Thanks,  
Sandeep

---

<div class="post-metadata">

**Author:** ![sgudibanda](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@sgudibanda](https://www.ruby-forum.com/u/sgudibanda)\
**Post date:** [June 9, 2009, 4:22pm UTC](https://www.ruby-forum.com/t/ruby-prof-for-watir-testcase-calls-win32ole-method-missing/169845/2 "2009-06-09T16:22:36Z")

</div>

Hi,

2009/6/9 Sandeep G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hi all,
> 
> I generated ruby profile for my test suite. In my profile i observed  
> that 10% of my test time is taken by WIN32OLE#method\_missing. It was  
> called 60077 times.
> 
> Can anyone please help me understand when and why it is getting called.  
> Is there any way to optimize it ?

That is the way WIN32OLE work. All properties and methods pass through  
method\_missing.

The C code can be written with Ruby code like this:

def method\_missing(id,\*args)  
method = id.to\_s  
if method[-1] == ?=  
method = method[0…-2]  
return ole\_propertyput(method,args.first)  
else  
return ole\_invoke(method, args,  
DISPATCH\_METHOD|DISPATCH\_PROPERTYGET, false)  
end  
end

Regards,  
Park H.
