summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorcharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-25 05:03:30 (GMT)
committercharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-25 05:03:30 (GMT)
commit5d7b5481ca60260ef05ee969c8b142143c4aa8c2 (patch)
tree484c920c961d1dc14b8745489589f97cd2ac0ee0 /benchmark
parented33fcae5a1e6fca6fc7e10776b579c668d35451 (diff)
* benchmark/bm_hash_shift.rb: add benchmark for Hash#shift
* hash.c (rb_hash_shift): use st_shift if hash is not being iterated to delete element without iterating the whole hash. * hash.c (shift_i): remove function * include/ruby/st.h (st_shift): add st_shift function * st.c (st_shift): ditto [Bug #8312] [ruby-core:54524] Patch by funny-falcon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/bm_hash_shift.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/benchmark/bm_hash_shift.rb b/benchmark/bm_hash_shift.rb
new file mode 100644
index 0000000..a645671
--- /dev/null
+++ b/benchmark/bm_hash_shift.rb
@@ -0,0 +1,10 @@
+h = {}
+
+10000.times do |i|
+ h[i] = nil
+end
+
+50000.times do
+ k, v = h.shift
+ h[k] = v
+end