sidekiq-benchmark 0.5.0 → 0.5.1
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 +4 -4
- data/README.md +1 -4
- data/lib/sidekiq-benchmark.rb +1 -0
- data/lib/sidekiq-benchmark/version.rb +1 -1
- data/lib/sidekiq-benchmark/web.rb +18 -5
- data/lib/sidekiq-benchmark/worker.rb +2 -2
- data/test/lib/web_test.rb +17 -12
- data/web/views/benchmarks.erb +25 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f1b169c529b283e1e168119469196b3e597cb52
|
4
|
+
data.tar.gz: 4baa60ef47937686077547331e5a993b0d0642ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d23555c511e4d08ab7a284ddf1069635ed153020798f5655ab0ec85f84c3a2a480beebb8f7c37ca4a6eed376ca3a3a0639d7eb74ce85d71ad8eed91da097a6
|
7
|
+
data.tar.gz: 0f577d9211c64b8e63f725b09312eff473eea8e3c4048e9d70877e9922d8f4746cb3e1db385a7999ef4e3e775b79d0cc8f39788fc978dd5d00cb673a6787580a
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ And then execute:
|
|
19
19
|
|
20
20
|
## Requirements
|
21
21
|
|
22
|
-
|
22
|
+
From version 0.5.0 works with Sidekiq 4.2 or newer
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
@@ -92,6 +92,3 @@ require 'sidekiq-benchmark/testing'
|
|
92
92
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
93
93
|
4. Push to the branch (`git push origin my-new-feature`)
|
94
94
|
5. Create new Pull Request
|
95
|
-
|
96
|
-
|
97
|
-
[](https://coderwall.com/kosmatov)
|
data/lib/sidekiq-benchmark.rb
CHANGED
@@ -23,11 +23,11 @@ module Sidekiq
|
|
23
23
|
@charts = {}
|
24
24
|
|
25
25
|
Sidekiq.redis do |conn|
|
26
|
-
@types = conn.smembers
|
26
|
+
@types = conn.smembers TYPES_KEY
|
27
27
|
@types.each do |type|
|
28
|
-
@charts[type] = {
|
28
|
+
@charts[type] = STAT_KEYS.reduce({}) { |a, e| a[e] = []; a }
|
29
29
|
|
30
|
-
total_key = "#{
|
30
|
+
total_key = "#{REDIS_NAMESPACE}:#{type}:total"
|
31
31
|
total_keys = conn.hkeys(total_key) - %w(start_time job_time finish_time)
|
32
32
|
|
33
33
|
total_time = conn.hget total_key, :job_time
|
@@ -37,7 +37,7 @@ module Sidekiq
|
|
37
37
|
@charts[type][:total] << [key, value.to_f.round(2)]
|
38
38
|
end
|
39
39
|
|
40
|
-
stats = conn.hgetall "#{
|
40
|
+
stats = conn.hgetall "#{REDIS_NAMESPACE}:#{type}:stats"
|
41
41
|
stats.each do |key, value|
|
42
42
|
@charts[type][:stats] << [key.to_f, value.to_i]
|
43
43
|
end
|
@@ -52,7 +52,20 @@ module Sidekiq
|
|
52
52
|
|
53
53
|
app.post "/benchmarks/remove" do
|
54
54
|
Sidekiq.redis do |conn|
|
55
|
-
keys =
|
55
|
+
keys = STAT_KEYS.map { |key| "#{REDIS_NAMESPACE}:#{params[:type]}:#{key}" }
|
56
|
+
conn.srem TYPES_KEY, params[:type]
|
57
|
+
conn.del keys
|
58
|
+
end
|
59
|
+
|
60
|
+
redirect "#{root_path}benchmarks"
|
61
|
+
end
|
62
|
+
app.post "/benchmarks/remove_all" do
|
63
|
+
Sidekiq.redis do |conn|
|
64
|
+
types = conn.smembers TYPES_KEY
|
65
|
+
keys = STAT_KEYS.map do |key|
|
66
|
+
types.map { |type| "#{REDIS_NAMESPACE}:#{type}:#{key}" }
|
67
|
+
end.flatten
|
68
|
+
keys << TYPES_KEY
|
56
69
|
conn.del keys
|
57
70
|
end
|
58
71
|
|
@@ -68,8 +68,8 @@ module Sidekiq
|
|
68
68
|
|
69
69
|
def set_redis_key(key)
|
70
70
|
Sidekiq.redis do |conn|
|
71
|
-
conn.sadd
|
72
|
-
conn.expire
|
71
|
+
conn.sadd TYPES_KEY, key
|
72
|
+
conn.expire TYPES_KEY, REDIS_KEYS_TTL
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
data/test/lib/web_test.rb
CHANGED
@@ -14,33 +14,38 @@ module Sidekiq
|
|
14
14
|
Test.flush_db
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "display index without stats" do
|
18
18
|
get '/benchmarks'
|
19
19
|
last_response.status.must_equal 200
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
22
|
+
it "display index with stats" do
|
23
23
|
WorkerMock.new
|
24
24
|
|
25
25
|
get '/benchmarks'
|
26
26
|
last_response.status.must_equal 200
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "remove all benchmarks data" do
|
30
30
|
WorkerMock.new
|
31
31
|
|
32
|
-
Sidekiq.redis
|
33
|
-
keys = conn.keys "benchmark:*"
|
34
|
-
keys.wont_be_empty
|
35
|
-
end
|
32
|
+
Sidekiq.redis { |conn| conn.keys("benchmark:*").wont_be_empty }
|
36
33
|
|
37
|
-
post '/benchmarks/
|
34
|
+
post '/benchmarks/remove_all'
|
38
35
|
last_response.status.must_equal 302
|
39
36
|
|
40
|
-
Sidekiq.redis
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
Sidekiq.redis { |conn| conn.keys("benchmark:*").must_be_empty }
|
38
|
+
end
|
39
|
+
|
40
|
+
it "remove benchmark data" do
|
41
|
+
WorkerMock.new
|
42
|
+
|
43
|
+
Sidekiq.redis { |conn| conn.keys("benchmark:sidekiq_benchmark_test_workermock:*").wont_be_empty }
|
44
|
+
|
45
|
+
post '/benchmarks/remove', type: :sidekiq_benchmark_test_workermock
|
46
|
+
last_response.status.must_equal 302
|
47
|
+
|
48
|
+
Sidekiq.redis { |conn| conn.keys("benchmark:sidekiq_benchmark_test_workermock:*").must_be_empty }
|
44
49
|
end
|
45
50
|
end
|
46
51
|
end
|
data/web/views/benchmarks.erb
CHANGED
@@ -5,11 +5,33 @@
|
|
5
5
|
<div class="col-md-6">
|
6
6
|
<h3>Benchmarks</h3>
|
7
7
|
</div>
|
8
|
+
|
9
|
+
<div class="col-md-6">
|
10
|
+
<form method="POST" class="warning-messages" action="<%= root_path %>benchmarks/remove_all">
|
11
|
+
<%= csrf_tag %>
|
12
|
+
<div class="pull-right">
|
13
|
+
<button class="btn btn-danger" type="submit" name="clear" value="1" data-confirm="<%= t('AreYouSure') %>"><%= t('DeleteAll') %></button>
|
14
|
+
</div>
|
15
|
+
</form>
|
16
|
+
</div>
|
8
17
|
</header>
|
9
18
|
|
10
|
-
<section>
|
11
19
|
<% @types.each do |type| %>
|
12
|
-
|
20
|
+
<section>
|
21
|
+
<div class="row">
|
22
|
+
<div class="col-md-6">
|
23
|
+
<h4><%= type %></h4>
|
24
|
+
</div>
|
25
|
+
<div class="col-md-6">
|
26
|
+
<form method="POST" class="warning-messages" action="<%= root_path %>benchmarks/remove">
|
27
|
+
<%= csrf_tag %>
|
28
|
+
<div class="pull-right">
|
29
|
+
<input type="hidden" name="type" value="<%= type %>"/>
|
30
|
+
<button class="btn btn-danger" type="submit" name="clear" value="1" data-confirm="<%= t('AreYouSure') %>"><%= t('Delete') %></button>
|
31
|
+
</div>
|
32
|
+
</form>
|
33
|
+
</div>
|
34
|
+
</div>
|
13
35
|
<figure class="row">
|
14
36
|
<div class="col-md-7">
|
15
37
|
<h5>Amount of tasks by execution time</h5>
|
@@ -20,5 +42,5 @@
|
|
20
42
|
<%= pie_chart @charts[type][:total] %>
|
21
43
|
</div>
|
22
44
|
</figure>
|
23
|
-
<% end %>
|
24
45
|
</section>
|
46
|
+
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-benchmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Kosmatov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|