Ruby Mail on CRuby, JRuby and IronRuby
Today I tried Mikel Lindsaar’s Mail gem on CRuby, JRuby and IronRuby.
Installation of each Ruby version and Mail gem was really easy so I will not describe it here. What interested me was how fast was Mail on each Ruby implementation.
I have created a simple mail and saved it as 1.eml.
Date: Thu, 24 Dec 2009 14:37:34 Central European Standard Time From: from@test.com To: to@test.com Message-ID: <4b336e9e762a0_a1014263a4689d3@2003-ie7.mail> Subject: This is a test email Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII"; Content-Transfer-Encoding: 7bit Some text for mail body
This script will read the file, display subject and time elapsed (in seconds).
time = Time.now
require "rubygems"
require "mail"
mail = Mail.read("1.eml")
puts mail.subject.to_s
puts Time.now - time
I have executed the script three times for each Ruby implementation. It looks to me that CRuby and JRuby are similar in speed, and IronRuby is way slower.
| Test Run | CRuby | JRuby | IronRuby |
|---|---|---|---|
| 1 | 2.594 | 3.0 | 9.8125 |
| 2 | 2.109 | 2.016 | 7.796875 |
| 3 | 2.11 | 2.0 | 7.6875 |

Heya Željko,
Thanks for the write up! Could I suggest a change to your testing methodology? Remove the rubygems and mail load from the test and run it using “benchmark”:http://ruby-doc.org/stdlib/libdoc/benchmark/rdoc/index.html
Also, might be a good idea to run the resulting test a few times more (like 100 or 1000) to remove any other ambiguity.
The time difference might be in the Rubygems load for all we know
Mikel
Mikel
24 Dec 09 at 10:00 pm
I strongly second what @Mikel said; testing the “main” gem’s performance should not take startup performance into account … which includes loading up RubyGems. From IronRuby, we know that start-up is significantly slower that MRI or JRuby (http://blog.jimmy.schementi.com/2009/12/ironruby-rubyconf-2009-part-4-project.html), so it would really help if you benchmarked this with benchmark.rb and ran it many more times. Also, using wall-clock time isn’t a great measurement of performance, so again, please use benchmark.rb.
Jimmy Schementi
24 Dec 09 at 10:27 pm
Thank you both for pointing me to benchmark.rb, I will take a look.
Željko Filipin
31 Dec 09 at 10:17 am
[...] blog post is update of my recent Ruby Mail on CRuby, JRuby and IronRuby post. Mikel and Jimmy have commented on the post saying I did a poor job, and I would agree. I [...]
Ruby Mail and benchmark.rb on CRuby, JRuby and IronRuby at Željko Filipin's Blog on Software and Testing
5 Jan 10 at 7:15 pm