sampling_prof 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sampling_prof.jar +0 -0
- data/lib/sampling_prof.rb +2 -0
- data/lib/sampling_prof/internal.rb +7 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55fa2ebf8d44c1f2cae2b54e7d12c06a52d6ee0f
|
4
|
+
data.tar.gz: 700e7f64be7f0dc5b2c9c38c95e4c80455ef136f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ede9199b87ecf2cfbd8a17ce955853cd00ddde02abb9f9f4a8a15eeb47bf36cfce22f213d88e8801c967b0096736d5155f9a087d8b28c5e27925d1611b6b7df
|
7
|
+
data.tar.gz: 0a33b15d7d041e1706a22cdb74935a0b0f9c7e4be06fa524b6a75ee150f3ae6986dabfb14f735b0114f7bc204b6f486c7e8c3d592ceeea3096ad66ddc1e4042e
|
data/lib/sampling_prof.jar
CHANGED
Binary file
|
data/lib/sampling_prof.rb
CHANGED
@@ -11,9 +11,11 @@ class SamplingProf
|
|
11
11
|
|
12
12
|
# options:
|
13
13
|
# sampling_interval: default to 0.1 second
|
14
|
+
# profiling_threshold: default to 0 second
|
14
15
|
# &output_handler: default to write into output_file
|
15
16
|
def initialize(*args, &output_handler)
|
16
17
|
self.sampling_interval = args[0] || 0.1
|
18
|
+
self.profiling_threshold = args[1] || 0
|
17
19
|
self.output_handler = block_given? ? output_handler : default_output_handler
|
18
20
|
internal_initialize if respond_to?(:internal_initialize)
|
19
21
|
end
|
@@ -60,7 +60,7 @@ class SamplingProf
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
attr_accessor :sampling_interval, :output_handler
|
63
|
+
attr_accessor :sampling_interval, :output_handler, :profiling_threshold
|
64
64
|
|
65
65
|
def internal_initialize
|
66
66
|
@samplings = {}
|
@@ -77,7 +77,9 @@ class SamplingProf
|
|
77
77
|
def stop
|
78
78
|
if @running
|
79
79
|
if sampling = @samplings.delete(Thread.current)
|
80
|
-
|
80
|
+
if sampling.sampling_data?
|
81
|
+
@output_handler.call(sampling.result)
|
82
|
+
end
|
81
83
|
true
|
82
84
|
end
|
83
85
|
end
|
@@ -103,23 +105,13 @@ class SamplingProf
|
|
103
105
|
@sampling_thread ||= Thread.start do
|
104
106
|
loop do
|
105
107
|
@samplings.dup.each do |t, s|
|
106
|
-
s.
|
108
|
+
if s.runtime >= @profiling_threshold
|
109
|
+
s.process(t)
|
110
|
+
end
|
107
111
|
end
|
108
112
|
sleep @sampling_interval
|
109
113
|
break unless @running
|
110
114
|
end
|
111
|
-
@samplings.each do |thread, sampling|
|
112
|
-
output(thread, sampling)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def output(thread, sampling)
|
118
|
-
if sampling.sampling_data?
|
119
|
-
o = @output_handler
|
120
|
-
thread.instance_eval do
|
121
|
-
o.call(sampling.result)
|
122
|
-
end
|
123
115
|
end
|
124
116
|
end
|
125
117
|
end
|