summaryrefslogtreecommitdiff
path: root/benchmark/gc/ring.rb
blob: e8b54a77d85bece38f3e9c86f6eda9d1762f85b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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