diff options
author | Charles Oliver Nutter <headius@headius.com> | 2015-11-23 14:16:47 -0600 |
---|---|---|
committer | Charles Oliver Nutter <headius@headius.com> | 2015-11-23 14:24:16 -0600 |
commit | a7b207d10943d2e587ffeb785f57203955c946fa (patch) | |
tree | 95348464acf257965917e374e9da2d6c7885ccc8 /activesupport/README.rdoc | |
parent | 762982f2325ce04a50f2f56b698b9fb7e606a518 (diff) | |
download | rails-a7b207d10943d2e587ffeb785f57203955c946fa.tar.gz rails-a7b207d10943d2e587ffeb785f57203955c946fa.tar.bz2 rails-a7b207d10943d2e587ffeb785f57203955c946fa.zip |
Test if each_object(singleton_class) works, since JRuby added it.
Fixes #22376.
JRuby 9.0.5.0 will support ObjectSpace.each_object against a
class's singleton class, since that's essentially just walking an
internal subclasses structure we already maintain. This test was
too narrow, requiring that each_object support an arbitrary class
but only actually needing it to work against a class's singleton.
This improves performance of Class.descendants by nearly two orders
of magnitude when run against JRuby 9.0.5.0:
```ruby
5.times { puts Benchmark.measure { 100_000.times { Numeric.descendants } } }
```
Before:
```
11.510000 0.140000 11.650000 ( 10.082384)
9.990000 0.020000 10.010000 ( 9.931233)
10.520000 0.040000 10.560000 ( 10.502978)
10.290000 0.030000 10.320000 ( 10.276027)
10.000000 0.030000 10.030000 ( 9.942429)
```
After:
```
1.380000 0.040000 1.420000 ( 0.365850)
0.210000 0.000000 0.210000 ( 0.149574)
0.180000 0.020000 0.200000 ( 0.141094)
0.140000 0.000000 0.140000 ( 0.140634)
0.190000 0.010000 0.200000 ( 0.147962)
```
Diffstat (limited to 'activesupport/README.rdoc')
0 files changed, 0 insertions, 0 deletions