NOTE: This is an archive of my old blog. Go to http://gonium.net for my current website.

Ruby 1.9 Performance

Posted by md on April 17, 2009

I’m currently using Ruby to optimize schedules based on a simulated annealing approach. For my current intermediate version I rely on marshalling internal datastructures really frequently. Out of curiosity I compared the runtimes of Ruby 1.8 and 1.9:

  • Ruby 1.8.6: 21 minutes, 55 seconds
  • Ruby 1.9.0: 22 minutes, 13 seconds

I certainly did not expect any wonders, but in theis case, the runtimes are about the same. So I’m investigating further, using the ruby 1.8 profiler on a smaller test problem:


% cumulative self self total
time seconds seconds calls ms/call ms/call name
33.20 32.96 32.96 661 49.86 77.25 Marshal.load
17.80 50.63 17.67 6365 2.78 14.96 Array#each
17.52 68.03 17.40 601659 0.03 0.03 IO#getc
9.19 77.15 9.12 660 13.82 13.82 Marshal.dump
6.01 83.12 5.97 187158 0.03 0.03 Float#+

My code spends 42.39 percent of its runtime doing marshalling operations. For Ruby 1.9, the code spends 48.98 percent of its runtime doing marshalling. This is somewhat disappointing. In a second round I changed my code to not relying on marshalling – basically, I am using clone on essential internal datastructures. All other information can be reconstructed afterwards. This means that I need to recompute certain values, but evidently this is a much faster approach:

  • Ruby 1.8.6: 1 minute, 34 seconds
  • Ruby 1.9.0: 1 minute, 17 seconds

Note to self: always use a profiler before refactoring code for performance reasons.

USBTemp v0.1.1 released

Posted by md on March 08, 2009

I just released a new version of USBTemp. This one includes some minor bugfixes:

  • The placement of C5 was wrong in the schematic.
  • The host software now compensates for some USB hickups.
  • The RRDTool graph generation script adds minimum, maximum and average temperature readings to the summary.

You can get the new version from the Mikrowerk page. The photo of the Galileo thermometer above was CC’ed on flickr by Nick Lawes.

New Temperature Page

Posted by md on January 08, 2009

I now publish the temperatures I am measuring in Kaiserslautern on the temperature page. Slightly easier to find ;-)