plotty 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +2 -2
- data/README.md +24 -1
- data/lib/plotty.rb +19 -0
- data/lib/plotty/graph.rb +51 -17
- data/lib/plotty/version.rb +21 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 016556c8fc016be7abc5fc5c5d61925aae7dbb33a82b9acd22213930e878ddcd
|
4
|
+
data.tar.gz: 7c205e096b7c9089550ebbcaa90925c7bf1dc90787571b62e444eb78d0534938
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2724ee565736c9040114287f65185d242364d5d3381841043da1b0b186530567c79ecb7af3fcbec9b212f4232d88dd3043b4aac2d9a68dd963ff1c63682b9f6
|
7
|
+
data.tar.gz: 6ba6bd7a79bc85e4431be4bffb0ba2f49a6507677c91d349d82d074a3c128bd4c73ac6823876b54a5f07ec8903d864f6ca865aa428fd7ea7137911deb1ec43f7
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -110,7 +110,30 @@ plotty -x 1:1:100 -y '\d+' -e "set terminal dumb; set key outside" -- 'echo $x'
|
|
110
110
|
|
111
111
|
### Web Server Benchmark
|
112
112
|
|
113
|
-
|
113
|
+
```
|
114
|
+
wrk -c $x -t $x -d 1 http://localhost:9292 *******
|
115
|
+
wrk -c $x -t $x -d 1 http://localhost:9293 #######
|
116
|
+
800 +--------------------------------------------------------------------+
|
117
|
+
| + + + + + |
|
118
|
+
700 |-+ ################################ +-|
|
119
|
+
| #### |
|
120
|
+
600 |-+ ### +-|
|
121
|
+
| #### |
|
122
|
+
| ## |
|
123
|
+
500 |-+ ## +-|
|
124
|
+
| ## |
|
125
|
+
400 |-+ # +-|
|
126
|
+
| ## |
|
127
|
+
300 |-+ # +-|
|
128
|
+
| # |
|
129
|
+
200 |-+ # +-|
|
130
|
+
| # |
|
131
|
+
| ##******************************************************* |
|
132
|
+
100 |-# +-|
|
133
|
+
|# + + + + + |
|
134
|
+
0 +--------------------------------------------------------------------+
|
135
|
+
0 50 100 150 200 250 300
|
136
|
+
```
|
114
137
|
|
115
138
|
## Contributing
|
116
139
|
|
data/lib/plotty.rb
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
1
20
|
|
2
21
|
require_relative "plotty/version"
|
3
22
|
require_relative "plotty/graph"
|
data/lib/plotty/graph.rb
CHANGED
@@ -55,22 +55,23 @@ module Plotty
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
58
|
+
Function = Struct.new(:pattern, :command, :title) do
|
59
|
+
def self.parse(pattern, command)
|
60
|
+
pattern = Regexp.new(pattern)
|
61
|
+
|
62
|
+
if command =~ /^(\w+):(.*?)$/
|
63
|
+
self.new(pattern, $2, $1)
|
64
|
+
else
|
65
|
+
self.new(pattern, command, command)
|
66
|
+
end
|
66
67
|
end
|
67
68
|
|
68
69
|
def call(value)
|
69
70
|
r, w = IO.pipe
|
70
71
|
|
71
|
-
puts "Running #{@command} with x = #{value}..."
|
72
|
+
# puts "Running #{@command} with x = #{value}..."
|
72
73
|
|
73
|
-
pid = Process.spawn({'x' => value.to_s},
|
74
|
+
pid = Process.spawn({'x' => value.to_s}, self.command, out: w, err: STDERR)
|
74
75
|
|
75
76
|
w.close
|
76
77
|
|
@@ -78,10 +79,10 @@ module Plotty
|
|
78
79
|
|
79
80
|
Process.waitpid pid
|
80
81
|
|
81
|
-
if match =
|
82
|
+
if match = self.pattern.match(buffer)
|
82
83
|
result = match[1] || match[0]
|
83
84
|
|
84
|
-
puts "\tresult = #{result}"
|
85
|
+
# puts "\tresult = #{result}"
|
85
86
|
|
86
87
|
return result
|
87
88
|
end
|
@@ -97,7 +98,7 @@ module Plotty
|
|
97
98
|
def self.parse(x, y, commands)
|
98
99
|
self.new(
|
99
100
|
Sequence.parse(x),
|
100
|
-
commands.collect{|command| Function.
|
101
|
+
commands.collect{|command| Function.parse(y, command)},
|
101
102
|
)
|
102
103
|
end
|
103
104
|
|
@@ -105,21 +106,54 @@ module Plotty
|
|
105
106
|
TTY::Screen.size.reverse
|
106
107
|
end
|
107
108
|
|
108
|
-
def
|
109
|
+
def generate_values
|
109
110
|
File.open("data.txt", "w") do |file|
|
111
|
+
file.sync = true
|
112
|
+
|
110
113
|
@x.each do |x|
|
111
114
|
values = @y.collect do |function|
|
112
115
|
function.call(x)
|
113
116
|
end
|
114
117
|
|
115
|
-
puts "#{x}: #{values.inspect}"
|
118
|
+
# puts "#{x}: #{values.inspect}"
|
116
119
|
file.puts "#{x} #{values.join(' ')}"
|
117
120
|
end
|
118
121
|
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def generate_plot(path = "plot.gp")
|
125
|
+
File.open(path, "w") do |file|
|
126
|
+
yield file if block_given?
|
127
|
+
|
128
|
+
file.write("plot ")
|
129
|
+
first = true
|
130
|
+
@y.collect.with_index do |function, index|
|
131
|
+
if first
|
132
|
+
first = false
|
133
|
+
else
|
134
|
+
file.write ','
|
135
|
+
end
|
136
|
+
|
137
|
+
file.write "'data.txt' using 1:#{index+2} with lines title #{function.title.dump}"
|
138
|
+
end
|
139
|
+
|
140
|
+
file.puts
|
141
|
+
|
142
|
+
# file.puts "pause 1"
|
143
|
+
# file.puts "reread"
|
144
|
+
end
|
119
145
|
|
120
|
-
|
146
|
+
return path
|
147
|
+
end
|
148
|
+
|
149
|
+
def plot!(script = nil)
|
150
|
+
generate_values
|
151
|
+
|
152
|
+
path = generate_plot do |file|
|
153
|
+
file.puts script if script
|
154
|
+
end
|
121
155
|
|
122
|
-
system("gnuplot",
|
156
|
+
system("gnuplot", path)
|
123
157
|
end
|
124
158
|
end
|
125
159
|
end
|
data/lib/plotty/version.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
1
21
|
module Plotty
|
2
|
-
VERSION = "0.
|
22
|
+
VERSION = "0.4.0"
|
3
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plotty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.6
|
125
|
+
rubygems_version: 2.7.6
|
126
126
|
signing_key:
|
127
127
|
specification_version: 4
|
128
128
|
summary: Draw graphs from data gathered by executing commands
|