The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Faster Messaging

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Laurent Sansonetti

Posts: 134
Nickname: lrz
Registered: Jun, 2006

Laurent Sansonetti is a software engineer at Apple Computer and a longtime Ruby enthusiast.
Faster Messaging Posted: Jun 8, 2007 1:53 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Laurent Sansonetti.
Original Post: Faster Messaging
Feed Title: lrz's diary
Feed URL: http://www.chopine.be/lrz/diary/xml/rss/feed.xml
Feed Description: lrz's diary
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Laurent Sansonetti
Latest Posts From lrz's diary

Advertisement

As you might already know, messaging Objective-C objects from Ruby works by hooking the method_missing method. This has the great advantage to be completely dynamic with the bridged API, since methods can be added to an existing Objective-C at runtime when loading a new framework. But it has also the inconvenient to be very slow.

I have been experimenting an idea to improve the performances, which is to actually define the Ruby methods at demand, so that method_missing would only be called once. This is fair enough when you consider that in a realistic application, the same code is ran multiple times during the application life.

I first tried that using define_method but realized that it was also very slow. Then I decided to go with something faster, at the C level: using Libffi to create closures and injects them into the Ruby runtime.

As expected it works very well, and on average it's ~3 times faster! See this message for the crusty numbers.

Read: Faster Messaging

Topic: Wolff Olins, the Olympic logo and a load of crap.. Previous Topic   Next Topic Topic: AT&T Online Support could use some QA

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use