time_bandits 0.6.5 → 0.6.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd2fea3396b9dc6b70fe418f7acd0955eba13231
|
4
|
+
data.tar.gz: 84ce369bee8fe66c3d610a52eb1baaf74bab6b54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3088b4806584633d9ea8b67f8f6ca9d50d0c3c6cd2c0780edcf88aa2db04f3d13690098d003259c678aae19682338dd601331b64ea1e3871f9bebede96a7f6b9
|
7
|
+
data.tar.gz: e03a9141f1107232b757e94df87f5fda7aac3b63315260e87e4f91d56c3cf2477e961734be5c0d599df4f4866669932c08c7e404cd0154a808679aa564f261c7
|
@@ -42,18 +42,29 @@ module ActiveRecord
|
|
42
42
|
hits
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
# Rails 4.1 uses method_added to automatically subscribe newly
|
46
|
+
# added methods. Since :render_bind and :sql are already defined,
|
47
|
+
# the net effect is that sql gets called twice. Therefore, we
|
48
|
+
# temporarily switch to protected mode and change it back later to
|
49
|
+
# public.
|
50
|
+
|
51
|
+
unless instance_methods.include?(:render_bind)
|
52
|
+
protected
|
53
|
+
def render_bind(column, value)
|
54
|
+
if column
|
55
|
+
if column.type == :binary
|
56
|
+
value = "<#{value.bytesize} bytes of binary data>"
|
57
|
+
end
|
58
|
+
[column.name, value]
|
59
|
+
else
|
60
|
+
[nil, value]
|
49
61
|
end
|
50
|
-
|
51
|
-
[column.name, value]
|
52
|
-
else
|
53
|
-
[nil, value]
|
54
62
|
end
|
55
|
-
|
63
|
+
public :render_bind
|
64
|
+
public
|
65
|
+
end
|
56
66
|
|
67
|
+
protected
|
57
68
|
def sql(event)
|
58
69
|
self.class.runtime += event.duration
|
59
70
|
self.class.call_count += 1
|
@@ -85,6 +96,8 @@ module ActiveRecord
|
|
85
96
|
debug " #{name} #{sql}#{binds}"
|
86
97
|
end
|
87
98
|
end
|
99
|
+
public :sql
|
100
|
+
public
|
88
101
|
|
89
102
|
module Railties
|
90
103
|
module ControllerRuntime
|
@@ -99,4 +112,3 @@ module ActiveRecord
|
|
99
112
|
end
|
100
113
|
end
|
101
114
|
end
|
102
|
-
|
data/lib/time_bandits/version.rb
CHANGED
data/test/unit/redis_test.rb
CHANGED
@@ -37,7 +37,28 @@ class RedisTest < Test::Unit::TestCase
|
|
37
37
|
assert_equal 0, m[:redis_time]
|
38
38
|
end
|
39
39
|
|
40
|
+
test "counts pipelined calls as single call" do
|
41
|
+
pipelined_work
|
42
|
+
m = TimeBandits.metrics
|
43
|
+
assert_equal 1, m[:redis_calls]
|
44
|
+
end
|
45
|
+
|
46
|
+
test "counts multi calls as single call" do
|
47
|
+
pipelined_work(:multi)
|
48
|
+
m = TimeBandits.metrics
|
49
|
+
assert_equal 1, m[:redis_calls]
|
50
|
+
end
|
51
|
+
|
40
52
|
private
|
53
|
+
def pipelined_work(type = :pipelined)
|
54
|
+
TimeBandits.reset
|
55
|
+
@redis.send(type) do
|
56
|
+
@redis.get("foo")
|
57
|
+
@redis.set("bar", 1)
|
58
|
+
@redis.hgetall("baz")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
41
62
|
def work
|
42
63
|
TimeBandits.reset
|
43
64
|
2.times do
|
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.6.
|
4
|
+
version: 0.6.6
|
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-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_variables
|