sampling_prof 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 09e40af6cfc090cd8cb6f7898ca0f51caf42c567
4
- data.tar.gz: 68069a76e4e43c35e3db126fe40fd60637aab510
5
- SHA512:
6
- metadata.gz: f7aa1b85fe7a29d053f3f10659807f3d7e22bc4479a5115261b23056803082ccc40844f37163956accc6b10b256a451ee7b1a7d4efb7c64999b7de90ff63fcf9
7
- data.tar.gz: 53ff7d0f03ca3b510dcba853fdaa9343e7abcf471d55f5d4648f0e9a2b2e665a33cb9a851624ecaba1f4acefefb365b52996ce1181681630524c1cb2e4a8736c
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 79d31489bf4da8c98f0c5e868eaad15001f552dc
4
+ data.tar.gz: 74e4a7286f56f2ddebd85c527e834dff51e87e9f
5
+ SHA512:
6
+ metadata.gz: 2583fd7fb1f8717427015e6df4e87fe30d3ae56a6628b9973bf9a9b9269a1bb9b1cd4a6c6ac8fc89c7d6dab2742377cb37ea45b0e7a2be7de8d98097fd9e7c0d
7
+ data.tar.gz: 1a480525f226a2a4c780ed44d9c172e1564356fe11bdd0ddd4c01080126fa84480c7ec709b130c39d3fd2f0939856aa1067eb0a83a4f0a0862646804ae756a66
Binary file
@@ -16,7 +16,7 @@ class SamplingProf
16
16
  end
17
17
 
18
18
  def result
19
- ret = [runtime * 1000]
19
+ ret = [@threads.sampling_runtime * 1000]
20
20
  ret << @nodes.map {|node| node.join(',')}.join("\n")
21
21
  ret << @samples.map {|count| count.flatten.join(',')}.join("\n")
22
22
  ret << @call_graph.map {|v| v.flatten.join(',')}.join("\n")
@@ -61,8 +61,9 @@ class SamplingProf
61
61
 
62
62
  class Threads
63
63
  def initialize
64
- @set = Set.new
64
+ @hash = {}
65
65
  @mutex = Mutex.new
66
+ @remain_sampling_time = 0
66
67
  end
67
68
 
68
69
  def each(&block)
@@ -70,15 +71,30 @@ class SamplingProf
70
71
  end
71
72
 
72
73
  def dup
73
- @mutex.synchronize { @set.dup }
74
+ @mutex.synchronize { @hash.keys.dup }
74
75
  end
75
76
 
76
77
  def add(obj)
77
- @mutex.synchronize { @set.add(obj) }
78
+ @mutex.synchronize { @hash[obj] = Time.now }
79
+ end
80
+
81
+ def sampling_runtime
82
+ now = Time.now
83
+ @mutex.synchronize do
84
+ ret, @remain_sampling_time = @remain_sampling_time, 0
85
+ @hash.keys.each do |k|
86
+ ret += now - @hash[k]
87
+ @hash[k] = now
88
+ end
89
+ ret
90
+ end
78
91
  end
79
92
 
80
93
  def delete(obj)
81
- @mutex.synchronize { @set.delete(obj) }
94
+ @mutex.synchronize do
95
+ start = @hash.delete(obj)
96
+ @remain_sampling_time += Time.now - start
97
+ end
82
98
  end
83
99
  end
84
100
 
metadata CHANGED
@@ -1,69 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sampling_prof
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
5
  platform: ruby
6
- authors:
7
- - Xiao Li
6
+ authors:
7
+ - Xiao Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-25 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake-compiler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.9'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.9.2
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '0.9'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.9.2
11
+
12
+ date: 2014-03-27 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
33
27
  description: |
34
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
35
- email:
36
- - swing1979@gmail.com
29
+
30
+ email:
31
+ - swing1979@gmail.com
37
32
  executables: []
33
+
38
34
  extensions: []
35
+
39
36
  extra_rdoc_files: []
40
- files:
41
- - README.md
42
- - lib/sampling_prof.jar
43
- - lib/sampling_prof.rb
44
- - lib/sampling_prof/internal.rb
37
+
38
+ files:
39
+ - README.md
40
+ - lib/sampling_prof.jar
41
+ - lib/sampling_prof.rb
42
+ - lib/sampling_prof/internal.rb
45
43
  homepage: https://github.com/xli/sampling_prof
46
- licenses:
47
- - MIT
44
+ licenses:
45
+ - MIT
48
46
  metadata: {}
47
+
49
48
  post_install_message:
50
49
  rdoc_options: []
51
- require_paths:
52
- - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: '0'
58
- required_rubygems_version: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - &id002
56
+ - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - *id002
63
62
  requirements: []
63
+
64
64
  rubyforge_project:
65
- rubygems_version: 2.2.0
65
+ rubygems_version: 2.1.9
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Simple sampling profiler for ruby
69
69
  test_files: []
70
+