sampling_prof 0.1.2 → 0.1.3
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/internal.rb +13 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd5ce616e57b19270ca4194dc382d4a4ee09367
|
4
|
+
data.tar.gz: 99c255e3688a28e30d2350f584bf4c4f0d024982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e518e426037a41899fca11bd5ab5485aadd7a9f5b10c19113dbbb32b6f9ce7dd69237aba938bf3cf7865c4249d3024d4dc2ed5c03a089979f60b87fb3a84145b
|
7
|
+
data.tar.gz: e05fc8223c08ebf488526438b1d52e1f39120ddd3aa389ced6e2661013240610ba7cb62e6d5fb4ef32f75ccc5dcb54d1396f76c0d96ce485773a3354ad04f985
|
data/lib/sampling_prof.jar
CHANGED
Binary file
|
@@ -4,8 +4,7 @@ class SamplingProf
|
|
4
4
|
end
|
5
5
|
|
6
6
|
class Sampling
|
7
|
-
def initialize
|
8
|
-
@target = target
|
7
|
+
def initialize
|
9
8
|
@samples = Hash.new{|h,k| h[k] = [0, 0] }
|
10
9
|
@call_graph = Hash.new{|h,k| h[k] = 0}
|
11
10
|
@nodes = {}
|
@@ -15,14 +14,14 @@ class SamplingProf
|
|
15
14
|
[@nodes.to_a, @samples.to_a, @call_graph.to_a]
|
16
15
|
end
|
17
16
|
|
18
|
-
def
|
19
|
-
locations = @target.backtrace_locations
|
17
|
+
def process(locations)
|
20
18
|
from = -1
|
21
19
|
paths = []
|
22
20
|
calls = []
|
21
|
+
top_index = locations.size - 1
|
23
22
|
locations.reverse.each_with_index do |loc, i|
|
24
|
-
node_id = node_id(loc
|
25
|
-
if i ==
|
23
|
+
node_id = node_id(loc)
|
24
|
+
if i == top_index
|
26
25
|
@samples[node_id][0] += 1
|
27
26
|
end
|
28
27
|
|
@@ -39,8 +38,12 @@ class SamplingProf
|
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
42
|
-
def node_id(
|
43
|
-
@nodes[
|
41
|
+
def node_id(loc)
|
42
|
+
@nodes[call_element(loc)] ||= @nodes.size
|
43
|
+
end
|
44
|
+
|
45
|
+
def call_element(loc)
|
46
|
+
[loc.path, loc.lineno, loc.label].join(":")
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
@@ -55,10 +58,10 @@ class SamplingProf
|
|
55
58
|
@running = true
|
56
59
|
target = Thread.current
|
57
60
|
@sampling_thread = Thread.start do
|
58
|
-
sampling = Sampling.new
|
61
|
+
sampling = Sampling.new
|
59
62
|
loop do
|
60
63
|
break unless @running
|
61
|
-
sampling.
|
64
|
+
sampling.process(target.backtrace_locations)
|
62
65
|
sleep @period
|
63
66
|
end
|
64
67
|
block.call(sampling.result)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sampling_prof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xiao Li
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-19 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|