|
This post originated from an RSS feed registered with Ruby Buzz
by Gregory Brown.
|
Original Post: New Formatting System: Cooler AND Faster
Feed Title: Ruby Reports Blog
Feed URL: http://www.cwinters.com/blog/index.rss
Feed Description: News and Updates regarding the Ruby Reports library and toolset.
|
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Gregory Brown
Latest Posts From Ruby Reports Blog
|
|
Even though Zed Shaw will have my head for awful benchmarking like this, it was my suspicion that the new formatting engine would some how be faster than the old one. Afterall, it doesn't bother to check for FasterCSV, it just assumes you have it, the code is cleaner which means it's less likely to be full of spazoidal stuff, and even though it relys more heavily on translating data into arrays, DataSet's new to_a method is much more efficient (thanks to Dudley Flanders).
So my little random shot in the dark script looks like this:
require "ruport"
a = [ [1,2],[3,4],[5,6] ].to_ds(%w[a b])
20000.times { a.as(:csv) }
And yes, it's your typical bad benchmark. Just picked a few random powers of ten until I found a sweet spot.
But take a look at the results:
Old System (0.4.4 includes the new formatting system, but DataSet still uses Format::Builder)
[sandal@harmonix rel_0_4_4]$ time ruby -Ilib -rubygems simple.rb
real 0m11.371s
user 0m11.025s
sys 0m0.324s
New System ( On SVN as of revision 287 )
[sandal@harmonix ruport]$ time ruby -Ilib -rubygems simple.rb
real 0m10.412s
user 0m10.185s
sys 0m0.200s
Whee, ~10% speed gain for free! :)
Read: New Formatting System: Cooler AND Faster