time_bandits 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -0
- data/Gemfile +1 -2
- data/README.rdoc +5 -1
- data/lib/time_bandits/time_consumers/garbage_collection.rb +34 -13
- data/lib/time_bandits/version.rb +1 -1
- data/test/unit/gc_consumer_test.rb +58 -0
- data/time_bandits.gemspec +2 -0
- metadata +67 -37
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
NzAxOTQ2ZDBlNzMyN2IzMWYzYTExOTc3MjVkNmE3MWUyYzBmOTAzNjZiZDgw
|
10
|
-
NjY0Y2M3NjZmNDA2NzQ1Nzk2MmE4YzAzMmNjY2NkZWNhYWMzZTE1ZGMzYzk3
|
11
|
-
NTJhZGZhMzNkZGQ5ZDQ3MGZiMzdhNDEyMGQ3ODAyYjFjZjE3Mjg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MmJjYWFiOGQxNDc1YjA5MWI1OTI1NWZlYTNmOGNlZTc1OWFlNWI1MDkxYmI5
|
14
|
-
N2YzNjEyMTRlMjc2MmFmZDFkZjIwNWJhMWE3Y2U0Y2Q2ZTAxN2EyZWIxYjhj
|
15
|
-
MDVjNjBkYjBmYjc5OTMwNmQ2ODU5ODM0ZDExZWU5ZjVhZmU5ZWQ=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9fae2e6cc7b44a9befcffb7c710c1f760119a17c
|
4
|
+
data.tar.gz: fa6a537a7fff153f5e30917c53f0a284f7d81db7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b813da44b27582d7be37fd98e5dc4c92cc4b05d00be9f3966cf7e98917f74bea5ff3e20e2f4a5f7885c67f513092082b844031db163a844ca3a1a1803fe2d40
|
7
|
+
data.tar.gz: 3ff9e7968d16b4462acd859a8280fbb24aad02fe90ed0036e735975ebac311ee882ae2063bda7c56b1cc1859b23e564b5c899c5e7d8ef7065a810e70cceae281
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -84,7 +84,11 @@ In order for the test to run you need a running memcached and redis-server
|
|
84
84
|
|
85
85
|
== Release Notes
|
86
86
|
|
87
|
-
version 0.
|
87
|
+
version 0.6.1
|
88
|
+
- switched to byebug (debugger does not full support 2.0 and 2.1 not at all)
|
89
|
+
- adapted garbage collection statistics to work for 2.1
|
90
|
+
|
91
|
+
version 0.6.0
|
88
92
|
- added redis time consumer
|
89
93
|
- fixed rails 4.0 problems with builtin mem_cache_store
|
90
94
|
- now only consumers which measured something are added to the completed line
|
@@ -18,6 +18,7 @@ module TimeBandits
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def enable_stats
|
21
|
+
return unless GC.respond_to? :enable_stats
|
21
22
|
GC.enable_stats
|
22
23
|
if defined?(PhusionPassenger)
|
23
24
|
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
@@ -26,13 +27,37 @@ module TimeBandits
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
30
|
+
if GC.respond_to?(:collections)
|
31
|
+
def _get_collections; GC.collections; end
|
32
|
+
elsif GC.respond_to?(:count)
|
33
|
+
def _get_collections; GC.count; end
|
34
|
+
else
|
35
|
+
def _get_collections; 0; end
|
36
|
+
end
|
37
|
+
|
38
|
+
if ObjectSpace.respond_to?(:allocated_objects)
|
39
|
+
def _get_allocated_objects; ObjectSpace.allocated_objects; end
|
40
|
+
elsif GC.respond_to?(:stat) && RUBY_VERSION >= "2.1.0"
|
41
|
+
def _get_allocated_objects; GC.stat(:total_allocated_object); end
|
42
|
+
else
|
43
|
+
def _get_allocated_objects; 0; end
|
44
|
+
end
|
45
|
+
|
46
|
+
if GC.respond_to?(:allocated_size)
|
47
|
+
def _get_allocated_size; GC.allocated_size; end
|
48
|
+
elsif GC.respond_to?(:total_malloced_bytes)
|
49
|
+
def _get_allocated_size; GC.total_malloced_bytes; end
|
50
|
+
else
|
51
|
+
def _get_allocated_size; 0; end
|
52
|
+
end
|
53
|
+
|
29
54
|
if GC.respond_to? :heap_slots
|
30
55
|
|
31
56
|
def reset
|
32
57
|
@consumed = GC.time
|
33
|
-
@collections =
|
34
|
-
@allocated_objects =
|
35
|
-
@allocated_size =
|
58
|
+
@collections = _get_collections
|
59
|
+
@allocated_objects = _get_allocated_objects
|
60
|
+
@allocated_size = _get_allocated_size
|
36
61
|
@heap_slots = GC.heap_slots
|
37
62
|
end
|
38
63
|
|
@@ -40,7 +65,7 @@ module TimeBandits
|
|
40
65
|
|
41
66
|
def reset
|
42
67
|
@consumed = GC.time
|
43
|
-
@collections =
|
68
|
+
@collections = _get_collections
|
44
69
|
end
|
45
70
|
|
46
71
|
end
|
@@ -54,17 +79,17 @@ module TimeBandits
|
|
54
79
|
end
|
55
80
|
|
56
81
|
def collections
|
57
|
-
|
82
|
+
_get_collections - @collections
|
58
83
|
end
|
59
84
|
|
60
85
|
if GC.respond_to? :heap_slots
|
61
86
|
|
62
87
|
def allocated_objects
|
63
|
-
|
88
|
+
_get_allocated_objects - @allocated_objects
|
64
89
|
end
|
65
90
|
|
66
91
|
def allocated_size
|
67
|
-
|
92
|
+
_get_allocated_size - @allocated_size
|
68
93
|
end
|
69
94
|
|
70
95
|
def heap_growth
|
@@ -72,13 +97,9 @@ module TimeBandits
|
|
72
97
|
end
|
73
98
|
|
74
99
|
if GC.respond_to? :heap_slots_live_after_last_gc
|
75
|
-
def live_data_set_size
|
76
|
-
GC.heap_slots_live_after_last_gc
|
77
|
-
end
|
100
|
+
def live_data_set_size; GC.heap_slots_live_after_last_gc; end
|
78
101
|
else
|
79
|
-
def live_data_set_size
|
80
|
-
0
|
81
|
-
end
|
102
|
+
def live_data_set_size; 0; end
|
82
103
|
end
|
83
104
|
|
84
105
|
GCFORMAT = "GC: %.3f(%d) | HP: %d(%d,%d,%d,%d)"
|
data/lib/time_bandits/version.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
class GCConsumerTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
TimeBandits.time_bandits = []
|
6
|
+
TimeBandits.add TimeBandits::TimeConsumers::GarbageCollection.instance
|
7
|
+
TimeBandits.reset
|
8
|
+
end
|
9
|
+
|
10
|
+
test "getting metrics" do
|
11
|
+
# example metrics hash:
|
12
|
+
sample = {
|
13
|
+
:gc_time => 0.5,
|
14
|
+
:gc_calls => 0,
|
15
|
+
:heap_growth => 0,
|
16
|
+
:heap_size => 116103,
|
17
|
+
:allocated_objects => 8,
|
18
|
+
:allocated_bytes => 152,
|
19
|
+
:live_data_set_size => 69437
|
20
|
+
}
|
21
|
+
m = TimeBandits.metrics
|
22
|
+
assert_equal sample.keys.sort, m.keys.sort
|
23
|
+
end
|
24
|
+
|
25
|
+
test "formatting" do
|
26
|
+
# example runtime:
|
27
|
+
# "GC: 0.000(0) | HP: 0(116101,6,0,69442)"
|
28
|
+
gc, heap = TimeBandits.runtime.split(' | ')
|
29
|
+
assert_equal "GC: 0.000(0)", gc
|
30
|
+
match = /\AHP: \d+\(\d+,\d+,\d+,\d+\)/
|
31
|
+
assert(heap =~ match, "#{heap} does not match #{match}")
|
32
|
+
end
|
33
|
+
|
34
|
+
test "collecting GC stats" do
|
35
|
+
work
|
36
|
+
check_work
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def work
|
41
|
+
TimeBandits.reset
|
42
|
+
a = []
|
43
|
+
10.times do |i|
|
44
|
+
a << (i.to_s * 100)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
def check_work
|
48
|
+
GC.start
|
49
|
+
m = TimeBandits.metrics
|
50
|
+
assert 0 < m[:gc_calls]
|
51
|
+
assert 0 < m[:gc_time]
|
52
|
+
assert 0 <= m[:heap_growth]
|
53
|
+
assert 0 < m[:heap_size]
|
54
|
+
assert 0 < m[:allocated_objects]
|
55
|
+
assert 0 < m[:allocated_bytes]
|
56
|
+
assert 0 <= m[:live_data_set_size]
|
57
|
+
end
|
58
|
+
end
|
data/time_bandits.gemspec
CHANGED
metadata
CHANGED
@@ -1,113 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_bandits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: thread_variables
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
|
-
- -
|
17
|
+
- - ">="
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
19
22
|
version_requirements: !ruby/object:Gem::Requirement
|
20
23
|
requirements:
|
21
|
-
- -
|
24
|
+
- - ">="
|
22
25
|
- !ruby/object:Gem::Version
|
23
26
|
version: '0'
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
name: thread_variables
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 2.3.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
33
36
|
version_requirements: !ruby/object:Gem::Requirement
|
34
37
|
requirements:
|
35
|
-
- -
|
38
|
+
- - ">="
|
36
39
|
- !ruby/object:Gem::Version
|
37
40
|
version: 2.3.2
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
name: activesupport
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
42
43
|
requirement: !ruby/object:Gem::Requirement
|
43
44
|
requirements:
|
44
|
-
- -
|
45
|
+
- - ">="
|
45
46
|
- !ruby/object:Gem::Version
|
46
47
|
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
47
50
|
version_requirements: !ruby/object:Gem::Requirement
|
48
51
|
requirements:
|
49
|
-
- -
|
52
|
+
- - ">="
|
50
53
|
- !ruby/object:Gem::Version
|
51
54
|
version: '0'
|
52
|
-
type: :development
|
53
|
-
prerelease: false
|
54
|
-
name: rake
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
+
name: mocha
|
56
57
|
requirement: !ruby/object:Gem::Requirement
|
57
58
|
requirements:
|
58
|
-
- -
|
59
|
+
- - ">="
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
61
64
|
version_requirements: !ruby/object:Gem::Requirement
|
62
65
|
requirements:
|
63
|
-
- -
|
66
|
+
- - ">="
|
64
67
|
- !ruby/object:Gem::Version
|
65
68
|
version: '0'
|
66
|
-
type: :development
|
67
|
-
prerelease: false
|
68
|
-
name: mocha
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
+
name: ansi
|
70
71
|
requirement: !ruby/object:Gem::Requirement
|
71
72
|
requirements:
|
72
|
-
- -
|
73
|
+
- - ">="
|
73
74
|
- !ruby/object:Gem::Version
|
74
75
|
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
75
78
|
version_requirements: !ruby/object:Gem::Requirement
|
76
79
|
requirements:
|
77
|
-
- -
|
80
|
+
- - ">="
|
78
81
|
- !ruby/object:Gem::Version
|
79
82
|
version: '0'
|
80
|
-
type: :development
|
81
|
-
prerelease: false
|
82
|
-
name: ansi
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
+
name: dalli
|
84
85
|
requirement: !ruby/object:Gem::Requirement
|
85
86
|
requirements:
|
86
|
-
- -
|
87
|
+
- - ">="
|
87
88
|
- !ruby/object:Gem::Version
|
88
89
|
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
89
92
|
version_requirements: !ruby/object:Gem::Requirement
|
90
93
|
requirements:
|
91
|
-
- -
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: redis
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
92
102
|
- !ruby/object:Gem::Version
|
93
103
|
version: '0'
|
94
104
|
type: :development
|
95
105
|
prerelease: false
|
96
|
-
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
112
|
+
name: memcached
|
98
113
|
requirement: !ruby/object:Gem::Requirement
|
99
114
|
requirements:
|
100
|
-
- -
|
115
|
+
- - ">="
|
101
116
|
- !ruby/object:Gem::Version
|
102
117
|
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
103
120
|
version_requirements: !ruby/object:Gem::Requirement
|
104
121
|
requirements:
|
105
|
-
- -
|
122
|
+
- - ">="
|
106
123
|
- !ruby/object:Gem::Version
|
107
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: minitest
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 4.7.5
|
108
132
|
type: :development
|
109
133
|
prerelease: false
|
110
|
-
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 4.7.5
|
111
139
|
description: Rails Completed Line on Steroids
|
112
140
|
email:
|
113
141
|
- skaes@railsexpress.de
|
@@ -115,7 +143,7 @@ executables: []
|
|
115
143
|
extensions: []
|
116
144
|
extra_rdoc_files: []
|
117
145
|
files:
|
118
|
-
- .gitignore
|
146
|
+
- ".gitignore"
|
119
147
|
- Gemfile
|
120
148
|
- README.rdoc
|
121
149
|
- README_RAILS2.rdoc
|
@@ -145,6 +173,7 @@ files:
|
|
145
173
|
- test/unit/active_support_notifications_test.rb
|
146
174
|
- test/unit/base_test.rb
|
147
175
|
- test/unit/dalli_test.rb
|
176
|
+
- test/unit/gc_consumer_test.rb
|
148
177
|
- test/unit/memcached_test.rb
|
149
178
|
- test/unit/redis_test.rb
|
150
179
|
- time_bandits.gemspec
|
@@ -158,17 +187,17 @@ require_paths:
|
|
158
187
|
- lib
|
159
188
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
189
|
requirements:
|
161
|
-
- -
|
190
|
+
- - ">="
|
162
191
|
- !ruby/object:Gem::Version
|
163
192
|
version: '0'
|
164
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
194
|
requirements:
|
166
|
-
- -
|
195
|
+
- - ">="
|
167
196
|
- !ruby/object:Gem::Version
|
168
197
|
version: '0'
|
169
198
|
requirements: []
|
170
199
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.0
|
200
|
+
rubygems_version: 2.2.0
|
172
201
|
signing_key:
|
173
202
|
specification_version: 4
|
174
203
|
summary: Custom performance logging for Rails
|
@@ -177,5 +206,6 @@ test_files:
|
|
177
206
|
- test/unit/active_support_notifications_test.rb
|
178
207
|
- test/unit/base_test.rb
|
179
208
|
- test/unit/dalli_test.rb
|
209
|
+
- test/unit/gc_consumer_test.rb
|
180
210
|
- test/unit/memcached_test.rb
|
181
211
|
- test/unit/redis_test.rb
|