Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Martin Hansen Newsgroups: comp.lang.ruby Subject: Re: Need for speed -> a C extension? Date: Tue, 19 Apr 2011 05:30:52 -0500 Organization: Service de news de lacave.net Lines: 35 Message-ID: <620c883309d2336f7741bf716b688aaf@ruby-forum.com> References: <4638db940d54573d9643ab0a369c8c7e@ruby-forum.com> <2CC4ECA8-9286-4431-AB2D-E7F0A67698FC@zenspider.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1303209140 224 65.111.164.187 (19 Apr 2011 10:32:20 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Tue, 19 Apr 2011 10:32:20 +0000 (UTC) In-Reply-To: <2CC4ECA8-9286-4431-AB2D-E7F0A67698FC@zenspider.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 381836 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <620c883309d2336f7741bf716b688aaf@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3155 >> def match?(char1, char2) >> (EQUAL[char1.upcase.ord] & EQUAL[char2.upcase.ord]) != 0 >> end > > That would be really easy to write tests and a benchmark against and > then rewrite in C using RubyInline... without tests and a benchmark tho, > you won't know that you've done it correctly and provides a measurable > benefit. They bottlenecks are the iteration over the sequence (while loop at line 68) and the vector_update (line 120). I am a bit surprised that match? is that slow - I expect it to be almost instantaneous in C. I would like to test that with a benchmark and Inline C. And I just discovered RubyInline! Inline code is so much easier to deal with that an external library IMHO. I have been messing a bit around with "inline", but that turns out to be some old crappy gem!!! Its not the first time I have missed the right gem :o( ... However, I get a peculiar error when testing RubyInline with the first of the examples: http://pastie.org/1811057 I am on Ruby 1.9.2. Cheers, Martin -- Posted via http://www.ruby-forum.com/.