aboutsummaryrefslogtreecommitdiffstats
path: root/benchmark
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-03 02:27:50 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-03 02:27:50 +0000
commit574422733dd11b242ba04c02579710e42fa58a77 (patch)
treea9c92e59c4b7b8b730f1e789b59e98a173fd1b5d /benchmark
parenta84bfcbf0061d30946e4d9692e9d4fa70682aef4 (diff)
downloadruby-574422733dd11b242ba04c02579710e42fa58a77.tar.gz
* array.c: Improve performance of Array#shift. use shared instead of
MEMMOVE if with arguments. Patch by @ksss [fix GH-537] * test/ruby/test_array.rb: ditto. * benchmark/bm_array_shift.rb: Added benchmark of GH-537 issue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/bm_array_shift.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/benchmark/bm_array_shift.rb b/benchmark/bm_array_shift.rb
new file mode 100644
index 0000000000..798bb9e3f4
--- /dev/null
+++ b/benchmark/bm_array_shift.rb
@@ -0,0 +1,14 @@
+require 'benchmark'
+
+Benchmark.bm do |x|
+ [10_000,1_000_000,100_000_000].each do |n|
+ ary = Array.new(n,0)
+ GC.start
+ x.report("#{n}:shift"){ ary.shift }
+ (0..4).each do |i|
+ ary = Array.new(n,0)
+ GC.start
+ x.report("#{n}:shift(#{i})"){ ary.shift(i) }
+ end
+ end
+end