ruby-changes:46232
From: mrkn <ko1@a...>
Date: Fri, 14 Apr 2017 14:19:18 +0900 (JST)
Subject: [ruby-changes:46232] mrkn:r58347 (trunk): Improve performance of type conversion using to_r
mrkn 2017-04-14 14:19:12 +0900 (Fri, 14 Apr 2017) New Revision: 58347 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58347 Log: Improve performance of type conversion using to_r * object.c: Add to_r in conv_method_tbl. * defs/id.def: add to_r. * benchmark/bm_int_quo.rb: added. * benchmark/bm_time_subsec.rb: added. [Bug #13426] [ruby-core:80665] [Fix GH-1582] Added files: trunk/benchmark/bm_int_quo.rb trunk/benchmark/bm_time_subsec.rb Modified files: trunk/defs/id.def trunk/object.c Index: defs/id.def =================================================================== --- defs/id.def (revision 58346) +++ defs/id.def (revision 58347) @@ -38,6 +38,7 @@ firstline, predefined = __LINE__+1, %[\ https://github.com/ruby/ruby/blob/trunk/defs/id.def#L38 to_a to_s to_i + to_r bt bt_locations call Index: object.c =================================================================== --- object.c (revision 58346) +++ object.c (revision 58347) @@ -2619,6 +2619,7 @@ static const struct conv_method_tbl { https://github.com/ruby/ruby/blob/trunk/object.c#L2619 M(a), M(s), M(i), + M(r), #undef M }; #define IMPLICIT_CONVERSIONS 7 Index: benchmark/bm_int_quo.rb =================================================================== --- benchmark/bm_int_quo.rb (nonexistent) +++ benchmark/bm_int_quo.rb (revision 58347) @@ -0,0 +1 @@ +5000000.times { 42.quo(3) } Index: benchmark/bm_time_subsec.rb =================================================================== --- benchmark/bm_time_subsec.rb (nonexistent) +++ benchmark/bm_time_subsec.rb (revision 58347) @@ -0,0 +1,2 @@ https://github.com/ruby/ruby/blob/trunk/benchmark/bm_time_subsec.rb#L1 +t = Time.now +4000000.times { t.subsec } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/