time_bandits 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/time_bandits/time_consumers/base_consumer.rb +6 -2
- data/lib/time_bandits/time_consumers/garbage_collection.rb +6 -0
- data/lib/time_bandits/version.rb +1 -1
- data/test/test_helper.rb +16 -6
- data/test/unit/active_support_notifications_test.rb +1 -0
- data/test/unit/gc_consumer_test.rb +14 -14
- data/time_bandits.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e78610739a238c4fdd8996c6d04233f55da3b2d
|
4
|
+
data.tar.gz: 4759fe23caee371f1a33ec748f2955f9377740f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e29f720c97c525431418c57d1551c6064b247afa12de33225c85564baa0c48ac506239b703c026cc65ccd849c61579a4b25bc92862546ef12eaaa0279cf26bf
|
7
|
+
data.tar.gz: db03cdbae7ad22d4c36fd637b75705c3ddcb32447a4de60ac2d90117268198fcd394b4bd8529d8c3cba733d3d04083f67c08a79adc953e58859c31650e94b3dd
|
data/Gemfile
CHANGED
@@ -2,8 +2,12 @@ module TimeBandits::TimeConsumers
|
|
2
2
|
class BaseConsumer
|
3
3
|
class << self
|
4
4
|
def instance
|
5
|
-
Thread.current.thread_variable_get(
|
6
|
-
Thread.current.thread_variable_set(
|
5
|
+
Thread.current.thread_variable_get(key) ||
|
6
|
+
Thread.current.thread_variable_set(key, new)
|
7
|
+
end
|
8
|
+
|
9
|
+
def key
|
10
|
+
@key ||= name.to_sym
|
7
11
|
end
|
8
12
|
|
9
13
|
def prefix(sym)
|
@@ -43,6 +43,8 @@ module TimeBandits
|
|
43
43
|
|
44
44
|
if ObjectSpace.respond_to?(:allocated_objects)
|
45
45
|
def _get_allocated_objects; ObjectSpace.allocated_objects; end
|
46
|
+
elsif GC.respond_to?(:stat) && RUBY_VERSION >= "2.2.0"
|
47
|
+
def _get_allocated_objects; GC.stat(:total_allocated_objects); end
|
46
48
|
elsif GC.respond_to?(:stat) && RUBY_VERSION >= "2.1.0"
|
47
49
|
def _get_allocated_objects; GC.stat(:total_allocated_object); end
|
48
50
|
else
|
@@ -59,6 +61,8 @@ module TimeBandits
|
|
59
61
|
|
60
62
|
if GC.respond_to?(:heap_slots)
|
61
63
|
def _get_heap_slots; GC.heap_slots; end
|
64
|
+
elsif GC.respond_to?(:stat) && RUBY_VERSION >= "2.2.0"
|
65
|
+
def _get_heap_slots; GC.stat(:heap_live_slots) + GC.stat(:heap_free_slots) + GC.stat(:heap_final_slots); end
|
62
66
|
elsif GC.respond_to?(:stat) && RUBY_VERSION >= "2.1.0"
|
63
67
|
def _get_heap_slots; GC.stat(:heap_live_slot) + GC.stat(:heap_free_slot) + GC.stat(:heap_final_slot); end
|
64
68
|
else
|
@@ -67,6 +71,8 @@ module TimeBandits
|
|
67
71
|
|
68
72
|
if GC.respond_to?(:heap_slots_live_after_last_gc)
|
69
73
|
def live_data_set_size; GC.heap_slots_live_after_last_gc; end
|
74
|
+
elsif GC.respond_to?(:stat) && RUBY_VERSION >= "2.2.0"
|
75
|
+
def live_data_set_size; GC.stat(:heap_live_slots); end
|
70
76
|
elsif GC.respond_to?(:stat) && RUBY_VERSION >= "2.1.0"
|
71
77
|
def live_data_set_size; GC.stat(:heap_live_slot); end
|
72
78
|
else
|
data/lib/time_bandits/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,14 +1,24 @@
|
|
1
|
-
require '
|
1
|
+
require 'minitest'
|
2
2
|
require 'mocha/setup'
|
3
|
-
require 'active_support/testing/declarative'
|
4
|
-
|
5
3
|
require 'minitest/pride'
|
4
|
+
require 'minitest/autorun'
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
require 'active_support/testing/declarative'
|
7
|
+
module Test
|
8
|
+
module Unit
|
9
|
+
class TestCase < Minitest::Test
|
10
|
+
extend ActiveSupport::Testing::Declarative
|
11
|
+
def assert_nothing_raised(*)
|
12
|
+
yield
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
9
16
|
end
|
10
17
|
|
18
|
+
Minitest::Test.i_suck_and_my_tests_are_order_dependent!
|
19
|
+
|
11
20
|
require_relative '../lib/time_bandits'
|
21
|
+
require "byebug"
|
12
22
|
|
13
23
|
ActiveSupport::LogSubscriber.class_eval do
|
14
24
|
# need a logger, otherwise no data will be collected
|
@@ -21,7 +31,7 @@ end
|
|
21
31
|
module Rails
|
22
32
|
extend self
|
23
33
|
module VERSION
|
24
|
-
STRING = "4.
|
34
|
+
STRING = "4.1.8"
|
25
35
|
end
|
26
36
|
def cache
|
27
37
|
@cache ||= ActiveSupport::Cache.lookup_store(:mem_cache_store)
|
@@ -48,21 +48,21 @@ class GCConsumerTest < Test::Unit::TestCase
|
|
48
48
|
GC.start
|
49
49
|
m = TimeBandits.metrics
|
50
50
|
if GC.respond_to?(:time)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
assert_operator 0, :<, m[:gc_calls]
|
52
|
+
assert_operator 0, :<, m[:gc_time]
|
53
|
+
assert_instance_of Fixnum, m[:heap_growth]
|
54
|
+
assert_operator 0, :<, m[:heap_size]
|
55
|
+
assert_operator 0, :<, m[:allocated_objects]
|
56
|
+
assert_operator 0, :<, m[:allocated_bytes]
|
57
|
+
assert_operator 0, :<=, m[:live_data_set_size]
|
58
58
|
else
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
assert_operator 0, :<, m[:gc_calls]
|
60
|
+
assert_operator 0, :<=, m[:gc_time]
|
61
|
+
assert_instance_of Fixnum, m[:heap_growth]
|
62
|
+
assert_operator 0, :<, m[:heap_size]
|
63
|
+
assert_operator 0, :<, m[:allocated_objects]
|
64
|
+
assert_operator 0, :<=, m[:allocated_bytes]
|
65
|
+
assert_operator 0, :<, m[:live_data_set_size]
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/time_bandits.gemspec
CHANGED
@@ -28,6 +28,6 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency("memcached")
|
29
29
|
s.add_development_dependency("sequel")
|
30
30
|
s.add_development_dependency("mysql2")
|
31
|
-
s.add_development_dependency("minitest",
|
31
|
+
s.add_development_dependency("minitest", "~> 5.5")
|
32
32
|
end
|
33
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_bandits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_variables
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: '5.5'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: '5.5'
|
167
167
|
description: Rails Completed Line on Steroids
|
168
168
|
email:
|
169
169
|
- skaes@railsexpress.de
|
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
228
|
version: '0'
|
229
229
|
requirements: []
|
230
230
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.
|
231
|
+
rubygems_version: 2.4.5
|
232
232
|
signing_key:
|
233
233
|
specification_version: 4
|
234
234
|
summary: Custom performance logging for Rails
|