File: object_allocate.yml

package info (click to toggle)
ruby3.4 3.4.5-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 154,784 kB
  • sloc: ruby: 1,259,653; ansic: 829,955; yacc: 28,233; pascal: 7,359; sh: 3,864; python: 1,799; cpp: 1,158; asm: 808; makefile: 801; javascript: 414; lisp: 109; perl: 62; awk: 36; sed: 4; xml: 4
file content (48 lines) | stat: -rw-r--r-- 1,217 bytes parent folder | download
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