Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ujit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def self.runtime_stats
Primitive.get_stat_counters
end

# Discard statistics collected for --ujit-stats.
def self.reset_stats!
# defined in ujit_iface.c
Primitive.reset_stats_bang
end

class << self
private

Expand Down
13 changes: 13 additions & 0 deletions ujit_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,19 @@ get_stat_counters(rb_execution_context_t *ec, VALUE self)
#endif // if RUBY_DEBUG
}

// Primitive called in ujit.rb. Zero out all the counters.
static VALUE
reset_stats_bang(rb_execution_context_t *ec, VALUE self)
{
#if RUBY_DEBUG
vm_insns_count = 0;
rb_compiled_iseq_count = 0;
memset(&exit_op_count, 0, sizeof(exit_op_count));
memset(&ujit_runtime_counters, 0, sizeof(ujit_runtime_counters));
#endif // if RUBY_DEBUG
return Qnil;
}

#include "ujit.rbinc"

#if RUBY_DEBUG
Expand Down