sampling_prof 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5f8441784afcf541b8d966e7dc4c20d42f2397fc
4
+ data.tar.gz: f6b3b7907a5969f99e8618664d4c618623c93753
5
+ SHA512:
6
+ metadata.gz: ba5b7fac7a6fb71331d2c607938cd551a7d5de4588834c1ae7afd9bb0bf1a52cbec947693d185ab2736c550a12a42cb3de1da7ad028127e221db5c6af658c94a
7
+ data.tar.gz: cdf2248bbf978644aa72cbef7a5e85feb4c5eebc2b4da383ea9befa3796b91cac1c46cfee836728fc447734338247738cdc98b038551e162f4734fb32a5fa06f
data/README.md ADDED
File without changes
Binary file
@@ -0,0 +1,67 @@
1
+ require 'sampling_prof.jar'
2
+
3
+ class SamplingProf
4
+ DEFAULT_OUTPUT_FILE = 'profile.txt'
5
+
6
+ def profile(path=nil, &block)
7
+ start(path)
8
+ yield if block_given?
9
+ ensure
10
+ stop if block_given?
11
+ end
12
+
13
+ def start(path=nil)
14
+ __start__(&output(path))
15
+ end
16
+
17
+ def output(path=nil)
18
+ path ||= DEFAULT_OUTPUT_FILE
19
+ lambda do |data|
20
+ nodes, counts, call_graph = data
21
+ # puts "[DEBUG]data => #{data.inspect}"
22
+ File.open(path, 'w') do |f|
23
+ nodes.each do |node|
24
+ # node name, node id
25
+ f.puts node.join(',')
26
+ end
27
+ f.puts ""
28
+ counts.each do |count|
29
+ # node id, count
30
+ f.puts count.join(",")
31
+ end
32
+ f.puts ""
33
+ call_graph.each do |v|
34
+ # from node id, to node id, count
35
+ f.puts v.flatten.join(",")
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ def report(type, file=DEFAULT_OUTPUT_FILE)
42
+ file ||= DEFAULT_OUTPUT_FILE
43
+ nodes, counts, call_graph = File.read(file).split("\n\n")
44
+ nodes = nodes.split("\n").inject({}) do |ret, l|
45
+ n, i = l.split(',')
46
+ ret[i.to_i] = n
47
+ ret
48
+ end
49
+ counts = counts.split("\n").map do |l|
50
+ l.split(',').map(&:to_i)
51
+ end
52
+ total_count, report = flat_report(nodes, counts)
53
+ puts "total counts: #{total_count}"
54
+ puts "calls\t%\tname"
55
+ report.first(20).each do |v|
56
+ puts v.join("\t")
57
+ end
58
+ end
59
+
60
+ def flat_report(nodes, counts)
61
+ total = counts.map{|_,c| c}.reduce(:+)
62
+ reports = counts.sort_by{|_,c| -c}.map do |id, c|
63
+ [c, '%.2f%' % (100 * c.to_f/total), nodes[id]]
64
+ end
65
+ [total, reports]
66
+ end
67
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sampling_prof
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Xiao Li
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2014-02-07 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake-compiler
16
+ prerelease: false
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: "0.9"
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.9.2
25
+ type: :development
26
+ version_requirements: *id001
27
+ description: |
28
+ SamplingProf starts a thread to capture all of ruby threads stacktrace dump.
29
+
30
+ email:
31
+ - swing1979@gmail.com
32
+ executables: []
33
+
34
+ extensions: []
35
+
36
+ extra_rdoc_files: []
37
+
38
+ files:
39
+ - README.md
40
+ - lib/sampling_prof.jar
41
+ - lib/sampling_prof.rb
42
+ homepage: https://github.com/xli/sampling_prof
43
+ licenses:
44
+ - MIT
45
+ metadata: {}
46
+
47
+ post_install_message:
48
+ rdoc_options: []
49
+
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - &id002
55
+ - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - *id002
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 2.1.9
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Simple sampling profiler for JRuby
68
+ test_files: []
69
+