@@ -751,6 +751,41 @@ rb_gc_impl_zjit_writebarrier_required_offset(void)
751751 return -1 ;
752752}
753753
754+ /*
755+ * call-seq:
756+ * GC::MMTk.harness_begin
757+ *
758+ * A hook to be called before a benchmark begins.
759+ *
760+ * MMTk will do necessary preparations (such as triggering a full-heap GC)
761+ * and start collecting statistic data, such as the number of GC triggered,
762+ * time spent in GC, time spent in mutator, etc.
763+ */
764+ static VALUE
765+ rb_mmtk_harness_begin (VALUE _ )
766+ {
767+ mmtk_harness_begin (rb_gc_get_ractor_newobj_cache ());
768+
769+ return Qnil ;
770+ }
771+
772+ /*
773+ * call-seq:
774+ * GC::MMTk.harness_end
775+ *
776+ * A hook to be called after a benchmark ends.
777+ *
778+ * When this method is called, MMTk will stop collecting statistic data and
779+ * print out the data already collected.
780+ */
781+ VALUE
782+ rb_mmtk_harness_end (VALUE _ )
783+ {
784+ mmtk_harness_end ();
785+
786+ return Qnil ;
787+ }
788+
754789void
755790rb_gc_impl_init (void )
756791{
@@ -771,6 +806,10 @@ rb_gc_impl_init(void)
771806 rb_define_singleton_method (rb_mGC , "auto_compact=" , rb_f_notimplement , 1 );
772807 rb_define_singleton_method (rb_mGC , "latest_compact_info" , rb_f_notimplement , 0 );
773808 rb_define_singleton_method (rb_mGC , "verify_compaction_references" , rb_f_notimplement , -1 );
809+
810+ VALUE rb_mMMTk = rb_define_module_under (rb_mGC , "MMTk" );
811+ rb_define_singleton_method (rb_mMMTk , "harness_begin" , rb_mmtk_harness_begin , 0 );
812+ rb_define_singleton_method (rb_mMMTk , "harness_end" , rb_mmtk_harness_end , 0 );
774813}
775814
776815int
0 commit comments