ruby-changes:26523
From: nobu <ko1@a...>
Date: Sun, 23 Dec 2012 17:57:33 +0900 (JST)
Subject: [ruby-changes:26523] nobu:r38574 (trunk): profiler.rb: TracePoint
nobu 2012-12-23 17:57:22 +0900 (Sun, 23 Dec 2012) New Revision: 38574 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38574 Log: profiler.rb: TracePoint * lib/profiler.rb (Profiler__::PROFILE_PROC): use TracePoint. Modified files: trunk/ChangeLog trunk/lib/profiler.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 38573) +++ ChangeLog (revision 38574) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Dec 23 17:57:19 2012 Nobuyoshi Nakada <nobu@r...> + + * lib/profiler.rb (Profiler__::PROFILE_PROC): use TracePoint. + Sun Dec 23 16:13:00 2012 Zachary Scott <zachary@z...> * lib/erb.rb: typos for ERB::new link Index: lib/profiler.rb =================================================================== --- lib/profiler.rb (revision 38573) +++ lib/profiler.rb (revision 38574) @@ -60,14 +60,14 @@ https://github.com/ruby/ruby/blob/trunk/lib/profiler.rb#L60 module Profiler__ # internal values @@start = @@stack = @@map = @@array = nil - PROFILE_PROC = proc{|event, file, line, id, binding, klass| - case event - when "call", "c-call" + PROFILE_PROC = TracePoint.new(:call, :c_call, :return, :c_return) {|tp| + case tp.event + when :call, :c_call now = Process.times[0] @@stack.push [now, 0.0] - when "return", "c-return" + when :return, :c_return now = Process.times[0] - key = [klass, id] + key = [tp.defined_class, tp.method_id] if tick = @@stack.pop data = begin @@map[key] ||= [0, 0.0, 0.0, key] @@ -88,10 +88,10 @@ module_function https://github.com/ruby/ruby/blob/trunk/lib/profiler.rb#L88 @@stack = [] @@map = {} @@array = [] - set_trace_func PROFILE_PROC + PROFILE_PROC.enable end def stop_profile - set_trace_func nil + PROFILE_PROC.disable end def print_profile(f) stop_profile -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/