I'm running a simple CPU intensive benchmark:
puts (0..11).to_a.permutation.inject(0) { |m, _| m += 1 }
This takes around 158s with 1.9.3 and 200s with 2.0. Any thoughts on how
I can get performance back ?
Thanks.
on 2013-03-03 23:04
on 2013-03-04 06:00
On Mar 3, 2013, at 14:04, Bug Free <lists@ruby-forum.com> wrote: > I'm running a simple CPU intensive benchmark: > > puts (0..11).to_a.permutation.inject(0) { |m, _| m += 1 } > > This takes around 158s with 1.9.3 and 200s with 2.0. Any thoughts on how > I can get performance back ? I suggest you file a bug on http://bugs.ruby-lang.org. I also see the performance drop, about 8%. I profiled a smaller benchmark: $ ruby19 -v -rprofile -e '(0..7).to_a.permutation.inject(0) { |m, _| m += 1 }' ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1] % cumulative self self total time seconds seconds calls ms/call ms/call name 75.00 0.27 0.27 2 135.00 180.00 Array#permutation 25.00 0.36 0.09 40320 0.00 0.00 Fixnum#+ 0.00 0.36 0.00 1 0.00 0.00 Range#each 0.00 0.36 0.00 1 0.00 0.00 Enumerable.to_a 0.00 0.36 0.00 1 0.00 360.00 Enumerator#each 0.00 0.36 0.00 1 0.00 360.00 Enumerable.inject 0.00 0.36 0.00 1 0.00 360.00 #toplevel I'm unsure what this "nil#" method ruby 2 records is, or if it is only an artifact of TracePoint. It's also worth a bug report. $ ruby -v -rprofile -e '(0..7).to_a.permutation.inject(0) { |m, _| m += 1 }' ruby 2.0.0p0 (2013-02-24 revision 39473) [x86_64-darwin12.2.1] % cumulative self self total time seconds seconds calls ms/call ms/call name 52.31 0.34 0.34 40320 0.01 0.01 nil# 35.38 0.57 0.23 2 115.00 325.00 Array#permutation 12.31 0.65 0.08 40320 0.00 0.00 Fixnum#+ 0.00 0.65 0.00 1 0.00 0.00 TracePoint#enable 0.00 0.65 0.00 1 0.00 0.00 Enumerable#to_a 0.00 0.65 0.00 1 0.00 0.00 Range#each 0.00 0.65 0.00 1 0.00 650.00 Enumerator#each 0.00 0.65 0.00 1 0.00 650.00 Enumerable#inject 0.00 0.65 0.00 1 0.00 0.00 TracePoint#disable 0.00 0.65 0.00 1 0.00 650.00 #toplevel
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.