summaryrefslogtreecommitdiff
path: root/test/objspace/test_objspace.rb
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-08-18 09:41:38 +0200
committerAaron Patterson <aaron.patterson@gmail.com>2020-09-09 11:11:36 -0700
commit5001cc47169614ea07d87651c95c2ee185e374e0 (patch)
tree09f4891cd1a83559b4e4a4793a31c8dfbef64fc9 /test/objspace/test_objspace.rb
parent76c7146ab4bb86dc9474efee279a19d31c4374b2 (diff)
Optimize ObjectSpace.dump_all
The two main optimization are: - buffer writes for improved performance - avoid formatting functions when possible ``` | |compare-ruby|built-ruby| |:------------------|-----------:|---------:| |dump_all_string | 1.038| 195.925| | | -| 188.77x| |dump_all_file | 33.453| 139.645| | | -| 4.17x| |dump_all_dev_null | 44.030| 278.552| | | -| 6.33x| ```
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3420
Diffstat (limited to 'test/objspace/test_objspace.rb')
-rw-r--r--test/objspace/test_objspace.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index 7405b8864d..f9e6e82e8f 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -299,6 +299,12 @@ class TestObjSpace < Test::Unit::TestCase
assert_equal('{"type":"SYMBOL", "value":"foo"}', ObjectSpace.dump(:foo))
end
+ def test_dump_special_floats
+ assert_match(/"value":"NaN"/, ObjectSpace.dump(Float::NAN))
+ assert_match(/"value":"Inf"/, ObjectSpace.dump(Float::INFINITY))
+ assert_match(/"value":"\-Inf"/, ObjectSpace.dump(-Float::INFINITY))
+ end
+
def test_dump_dynamic_symbol
dump = ObjectSpace.dump(("foobar%x" % rand(0x10000)).to_sym)
assert_match(/"type":"SYMBOL"/, dump)