[前][次][番号順一覧][スレッド一覧]

ruby-changes:60179

From: Koichi <ko1@a...>
Date: Tue, 25 Feb 2020 13:14:23 +0900 (JST)
Subject: [ruby-changes:60179] 670b7be6c5 (master): should count only string.

https://git.ruby-lang.org/ruby.git/commit/?id=670b7be6c5

From 670b7be6c5fb9c3438fb6e36070401f25806f725 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Tue, 25 Feb 2020 13:12:53 +0900
Subject: should count only string.

This code can generate CC objects so we only need to count
existing String objects.

diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index 98ddbef..3c799b7 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -266,10 +266,13 @@ class TestHash < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_hash.rb#L266
   end
 
   def test_AREF_fstring_key
+    # warmup ObjectSpace.count_objects
+    ObjectSpace.count_objects
+
     h = {"abc" => 1}
-    before = GC.stat(:total_allocated_objects)
+    before = ObjectSpace.count_objects[:T_STRING]
     5.times{ h["abc"] }
-    assert_equal before, GC.stat(:total_allocated_objects)
+    assert_equal before, ObjectSpace.count_objects[:T_STRING]
   end
 
   def test_ASET_fstring_key
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]