summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--benchmark/object_allocate.yml21
-rw-r--r--vm_insnhelper.c1
2 files changed, 22 insertions, 0 deletions
diff --git a/benchmark/object_allocate.yml b/benchmark/object_allocate.yml
new file mode 100644
index 0000000000..93ff463e41
--- /dev/null
+++ b/benchmark/object_allocate.yml
@@ -0,0 +1,21 @@
+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
+ # 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
+loop_count: 100000
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 2fa96373b6..f902a65f34 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -4034,6 +4034,7 @@ vm_declare_class(ID id, rb_num_t flags, VALUE cbase, VALUE super)
/* new class declaration */
VALUE s = VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) ? super : rb_cObject;
VALUE c = declare_under(id, cbase, rb_define_class_id(id, s));
+ rb_define_alloc_func(c, rb_get_alloc_func(c));
rb_class_inherited(s, c);
return c;
}