time_bandits 0.7.1 → 0.7.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c02c0496a8f416f2a02bd4ca1c95d45c5f16d72
4
- data.tar.gz: fae74e56ca2de98be7cd3baffea5e55c960d795e
3
+ metadata.gz: 2e78610739a238c4fdd8996c6d04233f55da3b2d
4
+ data.tar.gz: 4759fe23caee371f1a33ec748f2955f9377740f1
5
5
  SHA512:
6
- metadata.gz: 8667e3d1e7469130c909bdd62b6e28cda05ff499eef7c94cef32967e689405e5e7e4021151c8afb690d1e401886aae58df3d08624eed42f2abea4fc7f9379ee1
7
- data.tar.gz: 4e44865ab865d5406190c7437323ec2f0f3bd957ccd8296c7293cfe27bca26e5d39bdc5cdf8b017c5fd11f4115846cf62c963674187dd4692c64b7d35cdf35b6
6
+ metadata.gz: 9e29f720c97c525431418c57d1551c6064b247afa12de33225c85564baa0c48ac506239b703c026cc65ccd849c61579a4b25bc92862546ef12eaaa0279cf26bf
7
+ data.tar.gz: db03cdbae7ad22d4c36fd637b75705c3ddcb32447a4de60ac2d90117268198fcd394b4bd8529d8c3cba733d3d04083f67c08a79adc953e58859c31650e94b3dd
data/Gemfile CHANGED
@@ -4,6 +4,6 @@ source "http://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  # gem "activesupport", "3.2.13"
7
- gem "activesupport", "4.0.0"
7
+ gem "activesupport", "4.1.8"
8
8
 
9
9
  gem "byebug"
@@ -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(name) ||
6
- Thread.current.thread_variable_set(name, new)
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
@@ -1,3 +1,3 @@
1
1
  module TimeBandits
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -1,14 +1,24 @@
1
- require 'test/unit'
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
- class Test::Unit::TestCase
8
- extend ActiveSupport::Testing::Declarative
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.0.0"
34
+ STRING = "4.1.8"
25
35
  end
26
36
  def cache
27
37
  @cache ||= ActiveSupport::Cache.lookup_store(:mem_cache_store)
@@ -31,6 +31,7 @@ class ActiveSupportNotificationsTest < Test::Unit::TestCase
31
31
  end
32
32
 
33
33
  test "formatting" do
34
+ assert_same @bandit, TimeBandits.time_bandits.first.instance
34
35
  @bandit.calls = 1
35
36
  assert_equal "Simple: 0.0ms(1 calls)", TimeBandits.runtime
36
37
  end
@@ -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
- assert 0 < m[:gc_calls]
52
- assert 0 < m[:gc_time]
53
- assert 0 <= m[:heap_growth]
54
- assert 0 < m[:heap_size]
55
- assert 0 < m[:allocated_objects]
56
- assert 0 < m[:allocated_bytes]
57
- assert 0 <= m[:live_data_set_size]
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
- assert 0 < m[:gc_calls]
60
- assert 0 <= m[:gc_time]
61
- assert 0 <= m[:heap_growth]
62
- assert 0 < m[:heap_size]
63
- assert 0 < m[:allocated_objects]
64
- assert 0 <= m[:allocated_bytes]
65
- assert 0 < m[:live_data_set_size]
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", '~> 4.7.5')
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.1
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-10-23 00:00:00.000000000 Z
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: 4.7.5
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: 4.7.5
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.2.2
231
+ rubygems_version: 2.4.5
232
232
  signing_key:
233
233
  specification_version: 4
234
234
  summary: Custom performance logging for Rails