mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
profiler.rb: TracePoint
* lib/profiler.rb (Profiler__::PROFILE_PROC): use TracePoint. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cd6139cacd
commit
ef6abd10c7
2 changed files with 11 additions and 7 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Dec 23 17:57:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/profiler.rb (Profiler__::PROFILE_PROC): use TracePoint.
|
||||||
|
|
||||||
Sun Dec 23 16:13:00 2012 Zachary Scott <zachary@zacharyscott.net>
|
Sun Dec 23 16:13:00 2012 Zachary Scott <zachary@zacharyscott.net>
|
||||||
|
|
||||||
* lib/erb.rb: typos for ERB::new link
|
* lib/erb.rb: typos for ERB::new link
|
||||||
|
|
|
@ -60,14 +60,14 @@
|
||||||
module Profiler__
|
module Profiler__
|
||||||
# internal values
|
# internal values
|
||||||
@@start = @@stack = @@map = @@array = nil
|
@@start = @@stack = @@map = @@array = nil
|
||||||
PROFILE_PROC = proc{|event, file, line, id, binding, klass|
|
PROFILE_PROC = TracePoint.new(:call, :c_call, :return, :c_return) {|tp|
|
||||||
case event
|
case tp.event
|
||||||
when "call", "c-call"
|
when :call, :c_call
|
||||||
now = Process.times[0]
|
now = Process.times[0]
|
||||||
@@stack.push [now, 0.0]
|
@@stack.push [now, 0.0]
|
||||||
when "return", "c-return"
|
when :return, :c_return
|
||||||
now = Process.times[0]
|
now = Process.times[0]
|
||||||
key = [klass, id]
|
key = [tp.defined_class, tp.method_id]
|
||||||
if tick = @@stack.pop
|
if tick = @@stack.pop
|
||||||
data = begin
|
data = begin
|
||||||
@@map[key] ||= [0, 0.0, 0.0, key]
|
@@map[key] ||= [0, 0.0, 0.0, key]
|
||||||
|
@ -88,10 +88,10 @@ module_function
|
||||||
@@stack = []
|
@@stack = []
|
||||||
@@map = {}
|
@@map = {}
|
||||||
@@array = []
|
@@array = []
|
||||||
set_trace_func PROFILE_PROC
|
PROFILE_PROC.enable
|
||||||
end
|
end
|
||||||
def stop_profile
|
def stop_profile
|
||||||
set_trace_func nil
|
PROFILE_PROC.disable
|
||||||
end
|
end
|
||||||
def print_profile(f)
|
def print_profile(f)
|
||||||
stop_profile
|
stop_profile
|
||||||
|
|
Loading…
Add table
Reference in a new issue