summaryrefslogtreecommitdiff
path: root/benchmark/object_allocate.yml
blob: bdbd4536db2e6a99f5ccf4f084b231ab45797fb8 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
prelude: |
  class Eight
    8.times { include(Module.new) }
  end
  class ThirtyTwo
    32.times { include(Module.new) }
  end
  class SixtyFour
    64.times { include(Module.new) }
  end
  class OneTwentyEight
    128.times { include(Module.new) }
  end
  class OnePositional
    def initialize a; end
  end
  class TwoPositional
    def initialize a, b; end
  end
  class ThreePositional
    def initialize a, b, c; end
  end
  class FourPositional
    def initialize a, b, c, d; end
  end
  class KWArg
    def initialize a:, b:, c:, d:
    end
  end
  class Mixed
    def initialize a, b, c:, d:
    end
  end
  # Disable GC to see raw throughput:
  GC.disable
benchmark:
  allocate_8_deep: Eight.new
  allocate_32_deep: ThirtyTwo.new
  allocate_64_deep: SixtyFour.new
  allocate_128_deep: OneTwentyEight.new
  allocate_1_positional_params: OnePositional.new(1)
  allocate_2_positional_params: TwoPositional.new(1, 2)
  allocate_3_positional_params: ThreePositional.new(1, 2, 3)
  allocate_4_positional_params: FourPositional.new(1, 2, 3, 4)
  allocate_kwarg_params: "KWArg.new(a: 1, b: 2, c: 3, d: 4)"
  allocate_mixed_params: "Mixed.new(1, 2, c: 3, d: 4)"
  allocate_no_params: "Object.new"
loop_count: 100000