mergesort and mergesort hongli

2 views
Skip to first unread message

Jim Deville

unread,
Jun 26, 2009, 10:16:18 PM6/26/09
to ruby-bench...@googlegroups.com

Can someone help me justify having both of these? They both implement mergesort via the same techniques. One just uses easier to read code. For IronRuby, if I substitute mergesort_hongli’s Bench block with mergesort's Bench block, I get numbers that are almost identical (within .2s of each other). I’m guessing I’m missing something, so I’d like to know.

 

Thanks,

 

JD

 

…there is no try

 

Antonio Cangiano

unread,
Jun 27, 2009, 7:46:30 AM6/27/09
to ruby-bench...@googlegroups.com
On Fri, Jun 26, 2009 at 10:16 PM, Jim Deville <jdev...@microsoft.com> wrote:

Can someone help me justify having both of these? They both implement mergesort via the same techniques. One just uses easier to read code. For IronRuby, if I substitute mergesort_hongli’s Bench block with mergesort's Bench block, I get numbers that are almost identical (within .2s of each other). I’m guessing I’m missing something, so I’d like to know.

Thanks for bringing this up, Jim. We don't need them both. We can keep bm_mergesort.rb as long as we change the last part into something like this (this way, we'll exclude the setup time):

  fname = File.dirname(__FILE__) + "/random.input"
  array = File.read(fname).split(/\n/).map!{|m| m.to_i }
Bench.run [1] do |n|
   array.merge_sort
end


Cheers,
Antonio
--
High-quality programming screencasts: http://ThinkCode.TV
Zen and the Art of Programming: http://AntonioCangiano.com
Aperiodico di resistenza informatica: http://StackTrace.it
Author of "Ruby on Rails for Microsoft Developers": http://bit.ly/rorforms
Reply all
Reply to author
Forward
0 new messages