nchan_tools 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/nchan-benchmark +33 -9
- data/lib/nchan_tools/pubsub.rb +2 -2
- data/lib/nchan_tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ebb8bad8e4eab2ac6e0dafd8b93941d8001324158feadbd4638701d45b2ca0e
|
4
|
+
data.tar.gz: 89351ee1297b3b3bc01535e5da7a8fb2795ce16c0f3da3a7b1a5b89c2d6f4dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cf14c247f20f07962a1087f6f9adf509576dc6e0b9d6e9285ce30401847c038d5ab072bd259271cac48212ebcdf571283a52e30ee79fabf0e3bd884e801a50c
|
7
|
+
data.tar.gz: 7dc9a2ad487a014212fa27b936f5bab403f428403eb22bbede56705d17dbfc44daff7b30005b82fe6dfb2289cdb1b9a8857473290e5011584f7e565c556f4e5e
|
data/exe/nchan-benchmark
CHANGED
@@ -11,6 +11,8 @@ require "HDRHistogram"
|
|
11
11
|
verbose = false
|
12
12
|
save_csv = false
|
13
13
|
|
14
|
+
init_args = {}
|
15
|
+
|
14
16
|
opt_parser=OptionParser.new do |opts|
|
15
17
|
opts.on("-v", "--verbose", "somewhat rather extraneously wordful output") do
|
16
18
|
verbose = true
|
@@ -18,9 +20,23 @@ opt_parser=OptionParser.new do |opts|
|
|
18
20
|
opts.on("--csv FILENAME", "Append results to file in CSV format") do |f|
|
19
21
|
save_csv = f
|
20
22
|
end
|
21
|
-
|
23
|
+
opts.on("-t", "--time TIME", "Time to run benchmark") do |v|
|
24
|
+
init_args[:time] = v
|
25
|
+
end
|
26
|
+
opts.on("-r", "--msgrate NUMBER", "Message publishing rate per minute per channel") do |v|
|
27
|
+
init_args[:messages_per_channel_per_minute] = v
|
28
|
+
end
|
29
|
+
opts.on("-p", "--msgpadding NUMBER", "Message padding, in bytes") do |v|
|
30
|
+
init_args[:message_padding_bytes] = v
|
31
|
+
end
|
32
|
+
opts.on("-c", "--channels NUMBER", "Number of channels") do |v|
|
33
|
+
init_args[:channels] = v
|
34
|
+
end
|
35
|
+
opts.on("-s", "--subscribers NUMBER", "Subscribers per channel") do |v|
|
36
|
+
init_args[:subscribers_per_channel] = v
|
37
|
+
end
|
22
38
|
end
|
23
|
-
opt_parser.banner="Usage:
|
39
|
+
opt_parser.banner="Usage: nchan-benchmark [options] url1 url2 url3..."
|
24
40
|
opt_parser.parse!
|
25
41
|
|
26
42
|
urls = []
|
@@ -33,7 +49,9 @@ end
|
|
33
49
|
urls.uniq!
|
34
50
|
|
35
51
|
class Benchan
|
36
|
-
|
52
|
+
class BenchmarkError < StandardError
|
53
|
+
end
|
54
|
+
def initialize(urls, init_args=nil)
|
37
55
|
@urls = urls
|
38
56
|
@n = urls.count
|
39
57
|
@initializing = 0
|
@@ -44,6 +62,8 @@ class Benchan
|
|
44
62
|
@results = {}
|
45
63
|
@failed = {}
|
46
64
|
|
65
|
+
@init_args = init_args
|
66
|
+
|
47
67
|
@hdrh_publish = nil
|
48
68
|
@hdrh_receive = nil
|
49
69
|
|
@@ -66,14 +86,14 @@ class Benchan
|
|
66
86
|
sub.on_message do |msg|
|
67
87
|
msg = msg.to_s
|
68
88
|
case msg
|
69
|
-
when
|
89
|
+
when /^READY/
|
70
90
|
puts " #{sub.url} ok"
|
71
91
|
@ready +=1
|
72
92
|
if @ready == @n
|
73
93
|
control :run
|
74
94
|
puts "start benchmark..."
|
75
95
|
end
|
76
|
-
when
|
96
|
+
when /^RUNNING/
|
77
97
|
puts " #{sub.url} running"
|
78
98
|
when /^RESULTS\n/
|
79
99
|
msg = msg[8..-1]
|
@@ -81,9 +101,10 @@ class Benchan
|
|
81
101
|
@results[sub.url] = parsed
|
82
102
|
@results[sub.url]["raw"] = msg if @results[sub.url]
|
83
103
|
1+1
|
104
|
+
when /^INITIALIZING/
|
105
|
+
#do nothing
|
84
106
|
else
|
85
|
-
|
86
|
-
1+1
|
107
|
+
raise BenchmarkError, "unexpected server response: #{msg}"
|
87
108
|
end
|
88
109
|
end
|
89
110
|
@subs << sub
|
@@ -97,7 +118,7 @@ class Benchan
|
|
97
118
|
end
|
98
119
|
return if @failed.count > 0
|
99
120
|
puts "initializing benchmark..."
|
100
|
-
control :
|
121
|
+
control :init
|
101
122
|
self.wait
|
102
123
|
puts "finished."
|
103
124
|
puts ""
|
@@ -108,6 +129,9 @@ class Benchan
|
|
108
129
|
end
|
109
130
|
|
110
131
|
def control(msg)
|
132
|
+
if @init_args && (msg.to_sym ==:init || msg.to_sym ==:initialize)
|
133
|
+
msg = "#{msg.to_s} #{@init_args.map{|k,v| "#{k}=#{v}"}.join(" ")}"
|
134
|
+
end
|
111
135
|
@subs.each { |sub| sub.client.send_data msg.to_s }
|
112
136
|
end
|
113
137
|
|
@@ -237,7 +261,7 @@ class Benchan
|
|
237
261
|
end
|
238
262
|
end
|
239
263
|
|
240
|
-
benchan = Benchan.new urls
|
264
|
+
benchan = Benchan.new urls, init_args
|
241
265
|
benchan.run
|
242
266
|
benchan.results
|
243
267
|
benchan.append_csv_file(save_csv) if save_csv
|
data/lib/nchan_tools/pubsub.rb
CHANGED
@@ -248,7 +248,7 @@ class Subscriber
|
|
248
248
|
end
|
249
249
|
end
|
250
250
|
|
251
|
-
class SubscriberError <
|
251
|
+
class SubscriberError < StandardError
|
252
252
|
end
|
253
253
|
class Client
|
254
254
|
attr_accessor :concurrency
|
@@ -1646,7 +1646,7 @@ end
|
|
1646
1646
|
class Publisher
|
1647
1647
|
#include Celluloid
|
1648
1648
|
|
1649
|
-
class PublisherError <
|
1649
|
+
class PublisherError < StandardError
|
1650
1650
|
end
|
1651
1651
|
|
1652
1652
|
attr_accessor :messages, :response, :response_code, :response_body, :nofail, :accept, :url, :extra_headers, :verbose, :ws, :channel_info, :channel_info_type
|
data/lib/nchan_tools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nchan_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo Ponomarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|