aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-23 08:57:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-23 08:57:22 +0000
commitef6abd10c725bdf85d8b35a723cd0eca454bfcd7 (patch)
tree90dc9e8686040f177d8da7dda260d3227ec48a15
parentcd6139cacdef549b6eda975d55be80a9cf37fb4e (diff)
downloadruby-ef6abd10c725bdf85d8b35a723cd0eca454bfcd7.tar.gz
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
-rw-r--r--ChangeLog4
-rw-r--r--lib/profiler.rb14
2 files changed, 11 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 6826cedca6..c9854336c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* lib/erb.rb: typos for ERB::new link
diff --git a/lib/profiler.rb b/lib/profiler.rb
index ed787af267..3194ebaf48 100644
--- a/lib/profiler.rb
+++ b/lib/profiler.rb
@@ -60,14 +60,14 @@
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
@@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