aboutsummaryrefslogtreecommitdiffstats
path: root/benchmark
diff options
context:
space:
mode:
authortompng (tomoya ishida) <tomoyapenguin@gmail.com>2021-04-11 19:04:31 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-04-11 19:05:26 +0900
commit9f9045123efefbd11dd397b4d59596290765feec (patch)
tree7b7b4d76d96ca6be82e7c4d26eb3f5e161ea0d18 /benchmark
parent60bdf03b6d982777656acc11bdeb2ca4b4c3f1ef (diff)
downloadruby-9f9045123efefbd11dd397b4d59596290765feec.tar.gz
st.c: skip all deleted entries [Bug #17779]
Update the start entry skipping all already deleted entries. Fixes performance issue of `Hash#first` in a certain case.
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/hash_first.yml11
1 files changed, 11 insertions, 0 deletions
diff --git a/benchmark/hash_first.yml b/benchmark/hash_first.yml
new file mode 100644
index 0000000000..c26df1a7ed
--- /dev/null
+++ b/benchmark/hash_first.yml
@@ -0,0 +1,11 @@
+prelude: |
+ hash1 = 1_000_000.times.to_h { [rand, true]}
+ hash2 = hash1.dup
+ hash2.keys[1..100_000].each { hash2.delete _1 }
+ hash2.delete hash2.first[0]
+
+benchmark:
+ hash1: hash1.first
+ hash2: hash2.first
+
+loop_count: 100_000