diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-12 15:40:09 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-12 15:40:09 +0000 |
commit | c4c53310c23d913c1ff25863f1d9f7332b548f51 (patch) | |
tree | bd9e8449c51bba80d8ba40ddfc042704e417ee25 /benchmark/bm_vm2_poly_singleton.rb | |
parent | fd8fa1b29927918a40518481965735dc57a53811 (diff) | |
download | ruby-c4c53310c23d913c1ff25863f1d9f7332b548f51.tar.gz |
Copy the serial number from the super class to the singleton class
This helps hit inline method caches more frequently. Before this
commit:
```
[aaron@TC ruby (trunk)]$ time ./ruby -v benchmark/bm_vm2_poly_singleton.rb
ruby 2.4.0dev (2016-09-12 trunk 56141) [x86_64-darwin15]
real 0m3.679s
user 0m3.632s
sys 0m0.022s
```
After this commit:
```
[aaron@TC ruby (trunk)]$ time ./ruby -v benchmark/bm_vm2_poly_singleton.rb
ruby 2.4.0dev (2016-09-12 trunk 56141) [x86_64-darwin15]
last_commit=Copy the serial number from the super class to the singleton class
real 0m2.246s
user 0m2.203s
sys 0m0.020s
```
[Feature #12364]
[ruby-core:75425]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark/bm_vm2_poly_singleton.rb')
-rw-r--r-- | benchmark/bm_vm2_poly_singleton.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/benchmark/bm_vm2_poly_singleton.rb b/benchmark/bm_vm2_poly_singleton.rb new file mode 100644 index 0000000000..0dba4320c4 --- /dev/null +++ b/benchmark/bm_vm2_poly_singleton.rb @@ -0,0 +1,14 @@ +class C1 + def m; 1; end +end + +o1 = C1.new +o2 = C1.new +o2.singleton_class + +i = 0 +while i<6_000_000 # benchmark loop 2 + o = (i % 2 == 0) ? o1 : o2 + o.m; o.m; o.m; o.m; o.m; o.m; o.m; o.m + i += 1 +end |