summaryrefslogtreecommitdiff
path: root/jni/ruby/benchmark/gc/ring.rb
blob: be2c7b7250cbaab965f4cb0fd53f01365750c487 (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