Class: SamplingProfiler
- Inherits:
-
Object
- Object
- SamplingProfiler
- Defined in:
- lib/sampling_prof/internal.rb
Defined Under Namespace
Classes: Sampling
Instance Attribute Summary collapse
-
#sampling_interval ⇒ Object
Returns the value of attribute sampling_interval.
Instance Method Summary collapse
-
#initialize(sampling_interval) ⇒ SamplingProfiler
constructor
A new instance of SamplingProfiler.
- #profiling? ⇒ Boolean
- #start(output_handler) ⇒ Object
- #stop ⇒ Object
- #terminate ⇒ Object
Constructor Details
#initialize(sampling_interval) ⇒ SamplingProfiler
Returns a new instance of SamplingProfiler.
80 81 82 83 84 85 |
# File 'lib/sampling_prof/internal.rb', line 80 def initialize(sampling_interval) @sampling_interval = sampling_interval @samplings = {} @running = false start_sampling_thread end |
Instance Attribute Details
#sampling_interval ⇒ Object
Returns the value of attribute sampling_interval.
78 79 80 |
# File 'lib/sampling_prof/internal.rb', line 78 def sampling_interval @sampling_interval end |
Instance Method Details
#profiling? ⇒ Boolean
114 115 116 |
# File 'lib/sampling_prof/internal.rb', line 114 def profiling? !!@sampling_thread && @samplings.has_key?(Thread.current) end |
#start(output_handler) ⇒ Object
87 88 89 90 91 92 |
# File 'lib/sampling_prof/internal.rb', line 87 def start(output_handler) unless @samplings.has_key?(Thread.current) @samplings[Thread.current] = Sampling.new(output_handler) true end end |
#stop ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/sampling_prof/internal.rb', line 94 def stop if @running if sampling = @samplings[Thread.current] unless sampling.stopped? sampling.stop true end end end end |
#terminate ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/sampling_prof/internal.rb', line 105 def terminate return false unless @running @running = false @sampling_thread.join @sampling_thread = nil @samplings = {} true end |