« See all posts

Is Ruby 2.3 Faster? Date Parsing Performance

Posted by Alexander Dymo on February 02, 2016

Ruby 2.3 was released last month with yet another bunch of performance improvements. But is it really faster than 2.2? Let's take a look.

This is the second post in my series about Ruby 2.3 performance. This time we'll look at date parsing performance.

Date parsing became faster in Ruby 2.3. This is something I came across just today. It was neither announced as an improvement in the changelog, nor there's any indication that Date was optimized.

But the result is apparent. Consider this example:

require 'date'
require 'benchmark'


date = "2014-05-23"
time = Benchmark.realtime do
  100000.times do
puts "%.3f" % time

2.2.3 2.3.0
Date#parse performance 0.928 ± 0.011 s 0.843 ± 0.010 s

On the surface, it is nothing to write home about. 10% speedup that is only visible when parsing dates from the large datasets.

But if you look at the Ruby 2.2 to 2.3 diff, you will not find any optimizations in the Date parsing. It's also not the side-effect of faster garbage collection because I turned that off. So why is it faster then?

I'm yet to dig into details. But I think we can attribute the speedup to the performance improvements in the Ruby VM itself. If you know why exactly it's faster, please let me know.

Verdict: Faster

Date parsing is 10% faster. But it seems that's not the big news. Subtle optimizations in Ruby VM do yield tangible performance improvements. This is something that we see for the first time since Ruby 1.9.3.

Did you like this post? Follow me on Twitter or Google+ to stay updated on Ruby performance optimization news.

Next: Is Ruby 2.3 Faster? Rails ERB Template Rendering Performance
Previous: Is Ruby 2.3 Faster? Nested Iterator Performance