graph-function 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +8 -6
- data/examples/comparing.html +303 -0
- data/examples/comparing_canvas.rb +28 -0
- data/graph-function.gemspec +1 -0
- data/lib/graph/function.rb +1 -0
- data/lib/graph/function/comparison.rb +4 -1
- data/lib/graph/function/ints_comparison.rb +6 -1
- data/lib/graph/function/only.rb +3 -1
- data/lib/graph/function/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3928a98f9b9e14464ba42f12d15c1ed57c94e69
|
4
|
+
data.tar.gz: 09922b5d7483db4c3331124add4a25b5e07365ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6adec137335e29db10683a1e56efda5b074e9679647a2e33282e3d7b52e820361655ead33e9ab311999e08baecccaf347a66a0c508372a1ebfcc2797eff9a7
|
7
|
+
data.tar.gz: 530020596f1973d34a64e8253de722268a39b9cb3031d7b16e53fe3e2f22c1d5662cbfabd3459a9d258f4de9dae484f2187be0ca5fe0e650d296454bea7b3901
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -41,12 +41,12 @@ require 'graph/function'
|
|
41
41
|
Graph::Function.configure
|
42
42
|
```
|
43
43
|
|
44
|
-
If you don't want to output to x11, just set `config.terminal` to a different option like `
|
44
|
+
If you don't want to output to x11, just set `config.terminal` to a different option like `gif` (or anything else gnuplot [respects as a terminal](http://mibai.tec.u-ryukyu.ac.jp/~oshiro/Doc/gnuplot_primer/gptermcmp.html)). Output is the file location of output, and is ignored for x11.
|
45
45
|
|
46
46
|
```ruby
|
47
47
|
Graph::Function.configure do |config|
|
48
|
-
config.terminal = '
|
49
|
-
|
48
|
+
config.terminal = 'gif'
|
49
|
+
config.output = File.expand_path('../your_graph_name.gif', __FILE__)
|
50
50
|
end
|
51
51
|
```
|
52
52
|
|
@@ -60,19 +60,19 @@ Graph::Function::IntsComparison.of(c.method(:function_name_one), c.method(:funct
|
|
60
60
|
# => will output an xquartz graph
|
61
61
|
```
|
62
62
|
|
63
|
-
![comparison](two_func.
|
63
|
+
![comparison](spec/graph/two_func.gif)
|
64
64
|
|
65
65
|
If your functions need to operate on other types, then you need to generate values of those types. For this, I use [Rantly](https://github.com/hayeah/rantly). Here's an example of comparing two functions that take `Hash{String => Integer}`:
|
66
66
|
|
67
67
|
```ruby
|
68
68
|
generator = proc {|size| Rantly { dict(size) { [string, integer] } }
|
69
69
|
dict_comparison = Graph::Function::Comparison.new(generator)
|
70
|
-
#
|
70
|
+
# Comparison can take any number of Methods
|
71
71
|
dict_comparison.of(method(:hash_func_one), method(:hash_func_two))
|
72
72
|
# => will output an xquartz graph
|
73
73
|
```
|
74
74
|
|
75
|
-
![comparison](
|
75
|
+
![comparison](spec/graph/comparison.gif)
|
76
76
|
|
77
77
|
If you want to make use of more "real" fake data, [Faker](https://github.com/stympy/faker) is included, and can be used like so:
|
78
78
|
|
@@ -84,6 +84,8 @@ graph.of(method(:custom_types))
|
|
84
84
|
# => will output an xquartz graph
|
85
85
|
```
|
86
86
|
|
87
|
+
![faker](spec/graph/faker.gif)
|
88
|
+
|
87
89
|
The only downside here is that you can't parameterize `Faker`, but you could use random generators to mix it up. Using the above example, `graph-function` won't pass anything into the `faker_generator` but the `size`, so if we want the value to change, we could use `Faker::Date.backward(proc { rand(10) }.call)`.
|
88
90
|
|
89
91
|
Check out the [spec file](spec/graph/function_spec.rb) to see all of these and more examples.
|
@@ -0,0 +1,303 @@
|
|
1
|
+
<!DOCTYPE HTML>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Gnuplot Canvas Graph</title>
|
5
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
6
|
+
<!--[if IE]><script type="text/javascript" src="excanvas.js"></script><![endif]-->
|
7
|
+
<script src="/usr/local/Cellar/gnuplot/5.0.4/share/gnuplot/5.0/js/canvastext.js"></script>
|
8
|
+
<script src="/usr/local/Cellar/gnuplot/5.0.4/share/gnuplot/5.0/js/gnuplot_common.js"></script>
|
9
|
+
<script src="/usr/local/Cellar/gnuplot/5.0.4/share/gnuplot/5.0/js/gnuplot_dashedlines.js"></script>
|
10
|
+
<script type="text/javascript">gnuplot.init = function() {};</script>
|
11
|
+
<script type="text/javascript">
|
12
|
+
var canvas, ctx;
|
13
|
+
gnuplot.grid_lines = true;
|
14
|
+
gnuplot.zoomed = false;
|
15
|
+
gnuplot.active_plot_name = "gnuplot_canvas";
|
16
|
+
|
17
|
+
function gnuplot_canvas() {
|
18
|
+
canvas = document.getElementById("gnuplot_canvas");
|
19
|
+
ctx = canvas.getContext("2d");
|
20
|
+
// Gnuplot version 5.0.4
|
21
|
+
// short forms of commands provided by gnuplot_common.js
|
22
|
+
function DT (dt) {gnuplot.dashtype(dt);};
|
23
|
+
function DS (x,y) {gnuplot.dashstart(x,y);};
|
24
|
+
function DL (x,y) {gnuplot.dashstep(x,y);};
|
25
|
+
function M (x,y) {if (gnuplot.pattern.length > 0) DS(x,y); else gnuplot.M(x,y);};
|
26
|
+
function L (x,y) {if (gnuplot.pattern.length > 0) DL(x,y); else gnuplot.L(x,y);};
|
27
|
+
function Dot (x,y) {gnuplot.Dot(x/10.,y/10.);};
|
28
|
+
function Pt (N,x,y,w) {gnuplot.Pt(N,x/10.,y/10.,w/10.);};
|
29
|
+
function R (x,y,w,h) {gnuplot.R(x,y,w,h);};
|
30
|
+
function T (x,y,fontsize,justify,string) {gnuplot.T(x,y,fontsize,justify,string);};
|
31
|
+
function TR (x,y,angle,fontsize,justify,string) {gnuplot.TR(x,y,angle,fontsize,justify,string);};
|
32
|
+
function bp (x,y) {gnuplot.bp(x,y);};
|
33
|
+
function cfp () {gnuplot.cfp();};
|
34
|
+
function cfsp() {gnuplot.cfsp();};
|
35
|
+
|
36
|
+
gnuplot.hypertext_list = [];
|
37
|
+
gnuplot.on_hypertext = -1;
|
38
|
+
function Hypertext(x,y,w,text) {
|
39
|
+
newtext = {x:x, y:y, w:w, text:text};
|
40
|
+
gnuplot.hypertext_list.push(newtext);
|
41
|
+
}
|
42
|
+
gnuplot.dashlength = 400;
|
43
|
+
ctx.lineCap = "round"; ctx.lineJoin = "round";
|
44
|
+
CanvasTextFunctions.enable(ctx);
|
45
|
+
ctx.strokeStyle = "rgb(215,215,215)";
|
46
|
+
ctx.lineWidth = 1;
|
47
|
+
|
48
|
+
ctx.lineWidth = 1;
|
49
|
+
ctx.strokeStyle = "rgb(000,000,000)";
|
50
|
+
ctx.beginPath();
|
51
|
+
M(540,3680);
|
52
|
+
L(640,3680);
|
53
|
+
M(5759,3680);
|
54
|
+
L(5659,3680);
|
55
|
+
ctx.stroke();
|
56
|
+
ctx.closePath();
|
57
|
+
ctx.fillStyle = "rgb(000,000,000)";
|
58
|
+
T(460,3730,10.0,"Right"," 0");
|
59
|
+
ctx.beginPath();
|
60
|
+
M(540,3197);
|
61
|
+
L(640,3197);
|
62
|
+
M(5759,3197);
|
63
|
+
L(5659,3197);
|
64
|
+
ctx.stroke();
|
65
|
+
ctx.closePath();
|
66
|
+
T(460,3247,10.0,"Right"," 2");
|
67
|
+
ctx.beginPath();
|
68
|
+
M(540,2715);
|
69
|
+
L(640,2715);
|
70
|
+
M(5759,2715);
|
71
|
+
L(5659,2715);
|
72
|
+
ctx.stroke();
|
73
|
+
ctx.closePath();
|
74
|
+
T(460,2765,10.0,"Right"," 4");
|
75
|
+
ctx.beginPath();
|
76
|
+
M(540,2232);
|
77
|
+
L(640,2232);
|
78
|
+
M(5759,2232);
|
79
|
+
L(5659,2232);
|
80
|
+
ctx.stroke();
|
81
|
+
ctx.closePath();
|
82
|
+
T(460,2282,10.0,"Right"," 6");
|
83
|
+
ctx.beginPath();
|
84
|
+
M(540,1749);
|
85
|
+
L(640,1749);
|
86
|
+
M(5759,1749);
|
87
|
+
L(5659,1749);
|
88
|
+
ctx.stroke();
|
89
|
+
ctx.closePath();
|
90
|
+
T(460,1799,10.0,"Right"," 8");
|
91
|
+
ctx.beginPath();
|
92
|
+
M(540,1266);
|
93
|
+
L(640,1266);
|
94
|
+
M(5759,1266);
|
95
|
+
L(5659,1266);
|
96
|
+
ctx.stroke();
|
97
|
+
ctx.closePath();
|
98
|
+
T(460,1316,10.0,"Right"," 10");
|
99
|
+
ctx.beginPath();
|
100
|
+
M(540,784);
|
101
|
+
L(640,784);
|
102
|
+
M(5759,784);
|
103
|
+
L(5659,784);
|
104
|
+
ctx.stroke();
|
105
|
+
ctx.closePath();
|
106
|
+
T(460,834,10.0,"Right"," 12");
|
107
|
+
ctx.beginPath();
|
108
|
+
M(540,301);
|
109
|
+
L(640,301);
|
110
|
+
M(5759,301);
|
111
|
+
L(5659,301);
|
112
|
+
ctx.stroke();
|
113
|
+
ctx.closePath();
|
114
|
+
T(460,351,10.0,"Right"," 14");
|
115
|
+
ctx.beginPath();
|
116
|
+
M(540,3680);
|
117
|
+
L(540,3580);
|
118
|
+
M(540,301);
|
119
|
+
L(540,401);
|
120
|
+
ctx.stroke();
|
121
|
+
ctx.closePath();
|
122
|
+
T(540,3830,10.0,"Center"," 0");
|
123
|
+
ctx.beginPath();
|
124
|
+
M(1584,3680);
|
125
|
+
L(1584,3580);
|
126
|
+
M(1584,301);
|
127
|
+
L(1584,401);
|
128
|
+
ctx.stroke();
|
129
|
+
ctx.closePath();
|
130
|
+
T(1584,3830,10.0,"Center"," 2000");
|
131
|
+
ctx.beginPath();
|
132
|
+
M(2628,3680);
|
133
|
+
L(2628,3580);
|
134
|
+
M(2628,301);
|
135
|
+
L(2628,401);
|
136
|
+
ctx.stroke();
|
137
|
+
ctx.closePath();
|
138
|
+
T(2628,3830,10.0,"Center"," 4000");
|
139
|
+
ctx.beginPath();
|
140
|
+
M(3671,3680);
|
141
|
+
L(3671,3580);
|
142
|
+
M(3671,301);
|
143
|
+
L(3671,401);
|
144
|
+
ctx.stroke();
|
145
|
+
ctx.closePath();
|
146
|
+
T(3671,3830,10.0,"Center"," 6000");
|
147
|
+
ctx.beginPath();
|
148
|
+
M(4715,3680);
|
149
|
+
L(4715,3580);
|
150
|
+
M(4715,301);
|
151
|
+
L(4715,401);
|
152
|
+
ctx.stroke();
|
153
|
+
ctx.closePath();
|
154
|
+
T(4715,3830,10.0,"Center"," 8000");
|
155
|
+
ctx.beginPath();
|
156
|
+
M(5759,3680);
|
157
|
+
L(5759,3580);
|
158
|
+
M(5759,301);
|
159
|
+
L(5759,401);
|
160
|
+
ctx.stroke();
|
161
|
+
ctx.closePath();
|
162
|
+
T(5759,3830,10.0,"Center"," 10000");
|
163
|
+
ctx.beginPath();
|
164
|
+
M(540,301);
|
165
|
+
L(540,3680);
|
166
|
+
L(5759,3680);
|
167
|
+
L(5759,301);
|
168
|
+
L(540,301);
|
169
|
+
ctx.closePath();
|
170
|
+
ctx.stroke();
|
171
|
+
TR(90,2041,270,10.0,"Center","execution time");
|
172
|
+
T(3149,3980,10.0,"Center","input size");
|
173
|
+
T(3149,201,10.0,"Center","Sort vs BubbleSort");
|
174
|
+
if (typeof(gnuplot.hide_gp_plot_1) == "undefined"|| !gnuplot.hide_gp_plot_1) {
|
175
|
+
ctx.strokeStyle = "rgb(148,000,211)";
|
176
|
+
ctx.strokeStyle = "rgb(000,000,000)";
|
177
|
+
T(5099,514,10.0,"Right","sort");
|
178
|
+
ctx.strokeStyle = "rgb(148,000,211)";
|
179
|
+
ctx.beginPath();
|
180
|
+
M(5179,464);
|
181
|
+
L(5599,464);
|
182
|
+
M(540,3680);
|
183
|
+
L(1062,3680);
|
184
|
+
L(1584,3680);
|
185
|
+
L(2106,3680);
|
186
|
+
L(2628,3680);
|
187
|
+
L(3150,3680);
|
188
|
+
L(3671,3680);
|
189
|
+
L(4193,3680);
|
190
|
+
L(4715,3680);
|
191
|
+
L(5237,3680);
|
192
|
+
L(5759,3680);
|
193
|
+
ctx.stroke();
|
194
|
+
ctx.closePath();
|
195
|
+
Pt(0,540,3680,60.0);
|
196
|
+
Pt(0,1062,3680,60.0);
|
197
|
+
Pt(0,1584,3680,60.0);
|
198
|
+
Pt(0,2106,3680,60.0);
|
199
|
+
Pt(0,2628,3680,60.0);
|
200
|
+
Pt(0,3150,3680,60.0);
|
201
|
+
Pt(0,3671,3680,60.0);
|
202
|
+
Pt(0,4193,3680,60.0);
|
203
|
+
Pt(0,4715,3680,60.0);
|
204
|
+
Pt(0,5237,3680,60.0);
|
205
|
+
Pt(0,5759,3680,60.0);
|
206
|
+
Pt(0,5389,464,60.0);
|
207
|
+
} // End gp_plot_1
|
208
|
+
if (typeof(gnuplot.hide_gp_plot_2) == "undefined"|| !gnuplot.hide_gp_plot_2) {
|
209
|
+
ctx.lineWidth = 1;
|
210
|
+
ctx.strokeStyle = "rgb(000,000,000)";
|
211
|
+
DT(gnuplot.solid);
|
212
|
+
ctx.strokeStyle = "rgb(000,158,115)";
|
213
|
+
ctx.strokeStyle = "rgb(000,000,000)";
|
214
|
+
ctx.fillStyle = "rgb(000,000,000)";
|
215
|
+
ctx.beginPath();
|
216
|
+
M(5099,589);
|
217
|
+
M(4411,589);
|
218
|
+
ctx.stroke();
|
219
|
+
ctx.closePath();
|
220
|
+
T(4411,639,10.0,"","bubble_sort");
|
221
|
+
ctx.strokeStyle = "rgb(000,158,115)";
|
222
|
+
ctx.beginPath();
|
223
|
+
M(5179,589);
|
224
|
+
L(5599,589);
|
225
|
+
M(540,3680);
|
226
|
+
L(1062,3649);
|
227
|
+
L(1584,3559);
|
228
|
+
L(2106,3411);
|
229
|
+
L(2628,3192);
|
230
|
+
L(3150,2941);
|
231
|
+
L(3671,2601);
|
232
|
+
L(4193,2207);
|
233
|
+
L(4715,1772);
|
234
|
+
L(5237,1243);
|
235
|
+
L(5759,696);
|
236
|
+
ctx.stroke();
|
237
|
+
ctx.closePath();
|
238
|
+
Pt(1,540,3680,60.0);
|
239
|
+
Pt(1,1062,3649,60.0);
|
240
|
+
Pt(1,1584,3559,60.0);
|
241
|
+
Pt(1,2106,3411,60.0);
|
242
|
+
Pt(1,2628,3192,60.0);
|
243
|
+
Pt(1,3150,2941,60.0);
|
244
|
+
Pt(1,3671,2601,60.0);
|
245
|
+
Pt(1,4193,2207,60.0);
|
246
|
+
Pt(1,4715,1772,60.0);
|
247
|
+
Pt(1,5237,1243,60.0);
|
248
|
+
Pt(1,5759,696,60.0);
|
249
|
+
Pt(1,5389,589,60.0);
|
250
|
+
} // End gp_plot_2
|
251
|
+
ctx.lineWidth = 2;
|
252
|
+
ctx.strokeStyle = "rgb(000,000,000)";
|
253
|
+
DT(gnuplot.solid);
|
254
|
+
ctx.lineWidth = 1;
|
255
|
+
ctx.beginPath();
|
256
|
+
M(540,301);
|
257
|
+
L(540,3680);
|
258
|
+
L(5759,3680);
|
259
|
+
L(5759,301);
|
260
|
+
L(540,301);
|
261
|
+
ctx.closePath();
|
262
|
+
ctx.stroke();
|
263
|
+
|
264
|
+
// plot boundaries and axis scaling information for mousing
|
265
|
+
gnuplot.plot_term_xmax = 600;
|
266
|
+
gnuplot.plot_term_ymax = 400;
|
267
|
+
gnuplot.plot_xmin = 54.0;
|
268
|
+
gnuplot.plot_xmax = 575.9;
|
269
|
+
gnuplot.plot_ybot = 368.0;
|
270
|
+
gnuplot.plot_ytop = 30.1;
|
271
|
+
gnuplot.plot_width = 521.9;
|
272
|
+
gnuplot.plot_height = 337.9;
|
273
|
+
gnuplot.plot_axis_xmin = 0;
|
274
|
+
gnuplot.plot_axis_xmax = 10000;
|
275
|
+
gnuplot.plot_axis_ymin = 0;
|
276
|
+
gnuplot.plot_axis_ymax = 14;
|
277
|
+
gnuplot.plot_axis_x2min = "none"
|
278
|
+
gnuplot.plot_axis_y2min = "none"
|
279
|
+
gnuplot.plot_logaxis_x = 0;
|
280
|
+
gnuplot.plot_logaxis_y = 0;
|
281
|
+
gnuplot.plot_axis_width = gnuplot.plot_axis_xmax - gnuplot.plot_axis_xmin;
|
282
|
+
gnuplot.plot_axis_height = gnuplot.plot_axis_ymax - gnuplot.plot_axis_ymin;
|
283
|
+
gnuplot.plot_timeaxis_x = "";
|
284
|
+
gnuplot.plot_timeaxis_y = "";
|
285
|
+
}
|
286
|
+
</script>
|
287
|
+
<link type="text/css" href="/usr/local/Cellar/gnuplot/5.0.4/share/gnuplot/5.0/js/gnuplot_mouse.css" rel="stylesheet">
|
288
|
+
</head>
|
289
|
+
<body onload="gnuplot_canvas(); gnuplot.init();" oncontextmenu="return false;">
|
290
|
+
|
291
|
+
<div class="gnuplot">
|
292
|
+
<canvas id="Tile" width="32" height="32" hidden></canvas>
|
293
|
+
<table class="plot">
|
294
|
+
<tr><td>
|
295
|
+
<canvas id="gnuplot_canvas" width="600" height="400" tabindex="0">
|
296
|
+
Sorry, your browser seems not to support the HTML 5 canvas element
|
297
|
+
</canvas>
|
298
|
+
</td></tr>
|
299
|
+
</table>
|
300
|
+
</div>
|
301
|
+
|
302
|
+
</body>
|
303
|
+
</html>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'graph/function'
|
2
|
+
|
3
|
+
Graph::Function.configure do |config|
|
4
|
+
config.terminal = 'canvas'
|
5
|
+
config.output = File.expand_path('../comparing.html', __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
def bubble_sort(array)
|
9
|
+
n = array.length
|
10
|
+
loop do
|
11
|
+
swapped = false
|
12
|
+
(n-1).times do |i|
|
13
|
+
if array[i] > array[i+1]
|
14
|
+
array[i], array[i+1] = array[i+1], array[i]
|
15
|
+
swapped = true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
break if not swapped
|
19
|
+
end
|
20
|
+
array
|
21
|
+
end
|
22
|
+
|
23
|
+
def sort(array)
|
24
|
+
array.sort
|
25
|
+
end
|
26
|
+
|
27
|
+
puts 'comparing sort and bubble_sort'
|
28
|
+
Graph::Function::IntsComparison.of(method(:sort), method(:bubble_sort))
|
data/graph-function.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'gnuplot'
|
22
22
|
spec.add_dependency 'rantly'
|
23
23
|
spec.add_dependency 'faker'
|
24
|
+
spec.add_dependency 'ruby-progressbar'
|
24
25
|
spec.add_dependency 'benchmark-memory'
|
25
26
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
26
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/lib/graph/function.rb
CHANGED
@@ -19,13 +19,16 @@ module Graph
|
|
19
19
|
Gnuplot.open do |gp|
|
20
20
|
Gnuplot::Plot.new(gp) do |plot|
|
21
21
|
|
22
|
-
plot.title "#{methods.map {|m| camel_title(m.name) }.join(', ') }"
|
22
|
+
plot.title "#{title = methods.map {|m| camel_title(m.name) }.join(', ') }"
|
23
23
|
set_up(plot)
|
24
24
|
|
25
25
|
x = (0..10000).step(1000).to_a
|
26
|
+
pb = ProgressBar.create(title: title, total: x.size)
|
26
27
|
|
27
28
|
methods.each do |m|
|
29
|
+
pb.reset
|
28
30
|
y = x.collect do |v|
|
31
|
+
pb.increment
|
29
32
|
data = data_generator.call(v)
|
30
33
|
# FIXME can i get ride of the cost of `send`?
|
31
34
|
Benchmark.measure { self.send(m.name, data) }.real
|
@@ -12,12 +12,14 @@ module Graph
|
|
12
12
|
self.class.send(:define_method, :a, proc(&method_one))
|
13
13
|
self.class.send(:define_method, :b, proc(&method_two))
|
14
14
|
|
15
|
-
plot.title "#{camel_title(method_one.name)} vs #{camel_title(method_two.name)}"
|
15
|
+
plot.title (title = "#{camel_title(method_one.name)} vs #{camel_title(method_two.name)}")
|
16
16
|
set_up(plot)
|
17
17
|
|
18
18
|
x = (0..10000).step(1000).to_a
|
19
|
+
pb = ProgressBar.create(title: title, total: x.size)
|
19
20
|
|
20
21
|
y = x.collect do |v|
|
22
|
+
pb.increment
|
21
23
|
array = (0..v - 1).to_a.shuffle
|
22
24
|
Benchmark.measure { a(array) }.real
|
23
25
|
end
|
@@ -27,7 +29,10 @@ module Graph
|
|
27
29
|
ds.title = "#{escape_underscores(method_one.name)}"
|
28
30
|
end
|
29
31
|
|
32
|
+
pb.reset
|
33
|
+
|
30
34
|
z = x.collect do |v|
|
35
|
+
pb.increment
|
31
36
|
array = (0..v - 1).to_a.shuffle
|
32
37
|
Benchmark.measure { b(array) }.real
|
33
38
|
end
|
data/lib/graph/function/only.rb
CHANGED
@@ -17,12 +17,14 @@ module Graph
|
|
17
17
|
Gnuplot.open do |gp|
|
18
18
|
Gnuplot::Plot.new(gp) do |plot|
|
19
19
|
|
20
|
-
plot.title "#{camel_title(method_obj.name)}"
|
20
|
+
plot.title "#{title = camel_title(method_obj.name)}"
|
21
21
|
set_up(plot)
|
22
22
|
|
23
23
|
x = (0..10000).step(1000).to_a
|
24
|
+
pb = ProgressBar.create(title: title, total: x.size)
|
24
25
|
|
25
26
|
y = x.collect do |v|
|
27
|
+
pb.increment
|
26
28
|
data = data_generator.call(v)
|
27
29
|
Benchmark.measure { a(data) }.real
|
28
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graph-function
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Moore-Niemi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gnuplot
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ruby-progressbar
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: benchmark-memory
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +156,8 @@ files:
|
|
142
156
|
- bin/console
|
143
157
|
- bin/setup
|
144
158
|
- custom_comparison.jpg
|
159
|
+
- examples/comparing.html
|
160
|
+
- examples/comparing_canvas.rb
|
145
161
|
- graph-function.gemspec
|
146
162
|
- lib/graph/function.rb
|
147
163
|
- lib/graph/function/comparison.rb
|