mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Allow to toggle YJIT stats collection from runtime
For use cases where you want to collect the metrics for a specific piece of code (typically a web request) you can have the stats turned off by default and then turn them on at runtime before executing the code you care about.
This commit is contained in:
parent
924e3ca84f
commit
b5a0baf1c0
2 changed files with 15 additions and 0 deletions
8
yjit.rb
8
yjit.rb
|
@ -134,6 +134,14 @@ module YJIT
|
||||||
Primitive.reset_stats_bang
|
Primitive.reset_stats_bang
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.stats_enabled?
|
||||||
|
Primitive.cexpr! 'rb_yjit_opts.gen_stats ? Qtrue : Qfalse'
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.stats_enabled=(enabled)
|
||||||
|
Primitive.set_stats_enabled(enabled)
|
||||||
|
end
|
||||||
|
|
||||||
def self.enabled?
|
def self.enabled?
|
||||||
Primitive.cexpr! 'rb_yjit_enabled_p() ? Qtrue : Qfalse'
|
Primitive.cexpr! 'rb_yjit_enabled_p() ? Qtrue : Qfalse'
|
||||||
end
|
end
|
||||||
|
|
|
@ -808,6 +808,13 @@ reset_stats_bang(rb_execution_context_t *ec, VALUE self)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
set_stats_enabled(rb_execution_context_t *ec, VALUE self, VALUE enabled)
|
||||||
|
{
|
||||||
|
rb_yjit_opts.gen_stats = RB_TEST(enabled);
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
#include "yjit.rbinc"
|
#include "yjit.rbinc"
|
||||||
|
|
||||||
#if YJIT_STATS
|
#if YJIT_STATS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue