aboutsummaryrefslogtreecommitdiffstats
path: root/benchmark/gc/ring.rb
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-20 07:01:58 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-20 07:01:58 +0000
commit2802afffd688f4f3dce0492a45dab82bfc80e070 (patch)
tree862b381728c4b191bb525bc012f943bf43285034 /benchmark/gc/ring.rb
parentae39bfc5dc4685cd873f6bfbff3d1cc6adcc6f44 (diff)
downloadruby-2802afffd688f4f3dce0492a45dab82bfc80e070.tar.gz
* benchmark/gc/redblack.rb: import red black tree benchmark from
https://github.com/jruby/rubybench/blob/master/time/bench_red_black.rb * benchmark/gc/ring.rb: add a benchmark. This benchmark create many old objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41475 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'benchmark/gc/ring.rb')
-rw-r--r--benchmark/gc/ring.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/benchmark/gc/ring.rb b/benchmark/gc/ring.rb
new file mode 100644
index 0000000000..e8b54a77d8
--- /dev/null
+++ b/benchmark/gc/ring.rb
@@ -0,0 +1,29 @@
+# create many old objects
+
+max = 30_000_000
+
+class Ring
+ attr_reader :next_ring
+ def initialize n = nil
+ @next_ring = n
+ end
+
+
+ def size
+ s = 1
+ ring = self
+ while ring.next_ring
+ s += 1
+ ring = ring.next_ring
+ end
+ s
+ end
+end
+
+ring = Ring.new
+
+max.times{
+ ring = Ring.new(ring)
+}
+
+# p ring.size