From: ptkwt@... (Phil Tomson) Date: 2005-07-22T02:05:56+09:00 Subject: Re: C extension makes things slower In article <42DF4F1D.2060607@capitain.de>, Pit Capitain wrote: >Phil Tomson schrieb: >> And the results: >> l% ruby point.rb >> Total time for pure ruby point test: 8.600752 >> ACO_Ext initializing... >> Total time for extension point test: 6.086567 >> >> Using the extension it's 2.6 second _slower_ than the pure Ruby >> implementation!? > >Phil, 6 seconds is _faster_ than 8.6 seconds... > Yeah, but it's not as much faster as I wanted it to be Sheepish grin... Ah, right you are. Things look rather backwards at 1AM. However, here's the result of another run: Total time for pure ruby point test: 8.051388 ACO_Ext initializing... Total time for extension point test: 9.212984 There, I knew I wasn't hallucinating... Anyway, I'm starting to think that the variance might have more to do with loading of the machine I'm running on. Should probably use benchmark instead. Also, it was quite consistently slower (the C extension version) on my Powerbook, but then again I was running low on battery so that might have had something to do with it (still odd, though). In reality, the code above is just a small part of a much bigger program which includes more methods defined in C. When I ran that it was consistently slower by several seconds (actually almost twice as slow) when the extension was 'required'. That's what led me to start to time different sections of the C extenstion seperately in order to find the culprit. Phil