Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

capture duration for run

  • Loading branch information...
commit c3fa7f419308e81b29e5037f98ed93189e023513 1 parent 91500dd
@geemus authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/gestalt.rb
View
4 lib/gestalt.rb
@@ -7,7 +7,7 @@ class Gestalt
VERSION = '0.0.11'
- attr_accessor :bindings, :calls
+ attr_accessor :bindings, :calls, :duration
def initialize(options = {})
options = {
@@ -72,6 +72,7 @@ def display_profile
end
def run(&block)
+ started_at = Time.now
Kernel.set_trace_func(
lambda do |event, file, line, id, binding, classname|
@bindings << binding
@@ -102,6 +103,7 @@ def run(&block)
# noop
end
Kernel.set_trace_func(nil)
+ @duration = Time.now.to_f - started_at.to_f
@bindings.pop # pop Kernel#set_trace_func(nil)
@bindings.pop # pop Gestalt.run
@stack.pop # pop Kernel#set_trace_func(nil)
Please sign in to comment.
Something went wrong with that request. Please try again.