sampling_prof 0.0.1 → 0.0.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 +20 -14
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de9f6f4f7f21a996d3ecf1e922aa11fb43f8d2f2
|
4
|
+
data.tar.gz: d4ddca1249128c70847bf9a48e32a2698b34f178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 134db8e55f4756f8fde632e248021677befa69be81ec14b677b44220639cde040acca92781b32fbc327d3e836adf843b0d27f0e5e158290eae58f701ca4c818c
|
7
|
+
data.tar.gz: 43e57db9317d42ded4597ae974bd13671ae3c87bbfc766275c403d1eae06039a6473860f232049d6f09e1e72db04608f35f9a64bd5bda7a481932d0d9abce9a6
|
data/lib/sampling_prof.jar
CHANGED
Binary file
|
data/lib/sampling_prof.rb
CHANGED
@@ -3,23 +3,27 @@ require 'sampling_prof.jar'
|
|
3
3
|
class SamplingProf
|
4
4
|
DEFAULT_OUTPUT_FILE = 'profile.txt'
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
attr_accessor :output_file
|
7
|
+
|
8
|
+
def output_file
|
9
|
+
@output_file ||= DEFAULT_OUTPUT_FILE
|
10
|
+
end
|
11
|
+
|
12
|
+
def profile(&block)
|
13
|
+
start
|
8
14
|
yield if block_given?
|
9
15
|
ensure
|
10
16
|
stop if block_given?
|
11
17
|
end
|
12
18
|
|
13
|
-
def start
|
14
|
-
__start__(&output
|
19
|
+
def start
|
20
|
+
__start__(&output)
|
15
21
|
end
|
16
22
|
|
17
|
-
def output
|
18
|
-
path ||= DEFAULT_OUTPUT_FILE
|
23
|
+
def output
|
19
24
|
lambda do |data|
|
20
25
|
nodes, counts, call_graph = data
|
21
|
-
|
22
|
-
File.open(path, 'w') do |f|
|
26
|
+
File.open(output_file, 'w') do |f|
|
23
27
|
nodes.each do |node|
|
24
28
|
# node name, node id
|
25
29
|
f.puts node.join(',')
|
@@ -38,22 +42,23 @@ class SamplingProf
|
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
|
-
def report(type,
|
42
|
-
|
43
|
-
nodes, counts, call_graph = File.read(file).split("\n\n")
|
45
|
+
def report(type, output=$stdout)
|
46
|
+
nodes, counts, call_graph = File.read(output_file).split("\n\n")
|
44
47
|
nodes = nodes.split("\n").inject({}) do |ret, l|
|
45
48
|
n, i = l.split(',')
|
46
49
|
ret[i.to_i] = n
|
47
50
|
ret
|
48
51
|
end
|
52
|
+
|
49
53
|
counts = counts.split("\n").map do |l|
|
50
54
|
l.split(',').map(&:to_i)
|
51
55
|
end
|
52
56
|
total_count, report = flat_report(nodes, counts)
|
53
|
-
|
54
|
-
puts "
|
57
|
+
|
58
|
+
output.puts "total counts: #{total_count}"
|
59
|
+
output.puts "calls\t%\tname"
|
55
60
|
report.first(20).each do |v|
|
56
|
-
puts v.join("\t")
|
61
|
+
output.puts v.join("\t")
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
@@ -64,4 +69,5 @@ class SamplingProf
|
|
64
69
|
end
|
65
70
|
[total, reports]
|
66
71
|
end
|
72
|
+
|
67
73
|
end
|
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.0.
|
4
|
+
version: 0.0.2
|
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-08 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake-compiler
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
type: :development
|
26
26
|
version_requirements: *id001
|
27
27
|
description: |
|
28
|
-
SamplingProf
|
28
|
+
SamplingProf is a profiling tool that operates by sampling your running thread stacktrace. The result is statistical approximation, but it allows your code to run near full speed
|
29
29
|
|
30
30
|
email:
|
31
31
|
- swing1979@gmail.com
|
@@ -64,6 +64,6 @@ rubyforge_project:
|
|
64
64
|
rubygems_version: 2.1.9
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
|
-
summary: Simple sampling profiler
|
67
|
+
summary: Simple sampling profiler on JRuby
|
68
68
|
test_files: []
|
69
69
|
|