graph-function 0.1.7 → 0.2.0
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/graph-function.gemspec +1 -1
- data/lib/graph/function.rb +4 -1
- data/lib/graph/function/comparison.rb +5 -1
- data/lib/graph/function/plot_config.rb +10 -1
- data/lib/graph/function/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db0cb7f4f328670b3e50c017aee8e7cb2e751b5e
|
4
|
+
data.tar.gz: 4dc1a476b53979628653cfc4ca8b58e2877a334c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a65c9b5017291a906b829a48e52f3026394c10d92291169316ab661a5e8cedf0c4318f15534037995c853aed191f9733fb259043c722db7e615f76205e7e69a3
|
7
|
+
data.tar.gz: 2494046e069fc639949a25d9ad3677ce5f8f81bac798229fe13423a6a71b5f58c55691ba8324490e50c17219d9585513055d31cfd13f8a0cc48cebaf92dcd1da
|
data/graph-function.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency 'rantly'
|
23
23
|
spec.add_dependency 'faker'
|
24
24
|
spec.add_dependency 'ruby-progressbar'
|
25
|
-
spec.add_dependency '
|
25
|
+
spec.add_dependency 'memory_profiler'
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
data/lib/graph/function.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'gnuplot'
|
2
2
|
require 'benchmark'
|
3
|
+
require 'memory_profiler'
|
3
4
|
require 'rantly'
|
4
5
|
require 'faker'
|
5
6
|
require 'ruby-progressbar'
|
@@ -45,7 +46,7 @@ module Graph
|
|
45
46
|
class Configuration
|
46
47
|
attr_accessor :terminal, :output
|
47
48
|
attr_accessor :step
|
48
|
-
attr_accessor :trials
|
49
|
+
attr_accessor :trials, :memory
|
49
50
|
|
50
51
|
# defaults
|
51
52
|
# see https://github.com/rdp/ruby_gnuplot/blob/master/examples/output_image_file.rb
|
@@ -54,7 +55,9 @@ module Graph
|
|
54
55
|
@terminal = 'x11'
|
55
56
|
@output = '.'
|
56
57
|
@step = (0..10_000).step(1000).to_a
|
58
|
+
# these are particular to GF, not Gnuplot
|
57
59
|
@trials = 1
|
60
|
+
@memory = false
|
58
61
|
end
|
59
62
|
end
|
60
63
|
end
|
@@ -34,7 +34,11 @@ module Graph
|
|
34
34
|
pb.increment
|
35
35
|
data = data_generator.call(v)
|
36
36
|
current_trials = (1..trials).collect do |_|
|
37
|
-
|
37
|
+
if Graph::Function.configuration.memory
|
38
|
+
MemoryProfiler.report { f.call(data) }.total_allocated_memsize
|
39
|
+
else
|
40
|
+
Benchmark.measure { f.call(data) }.real
|
41
|
+
end
|
38
42
|
end
|
39
43
|
results[name][v] = current_trials
|
40
44
|
current_trials.reduce(0.0, :+) / trials
|
@@ -2,11 +2,20 @@ module Graph
|
|
2
2
|
module Function
|
3
3
|
module PlotConfig
|
4
4
|
def set_up(plot)
|
5
|
-
plot.ylabel
|
5
|
+
plot.ylabel ylabel
|
6
6
|
plot.xlabel 'input size'
|
7
7
|
plot.terminal (t = Graph::Function.configuration.terminal)
|
8
8
|
plot.output Graph::Function.configuration.output unless t == 'x11'
|
9
9
|
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def ylabel
|
13
|
+
if Graph::Function.configuration.memory
|
14
|
+
Graph::Function.configuration.trials == 1 ? 'total allocation memsize (bytes)' : 'average total allocation memsize (bytes)'
|
15
|
+
else
|
16
|
+
Graph::Function.configuration.trials == 1 ? 'execution time (seconds)' : 'average execution time (seconds)'
|
17
|
+
end
|
18
|
+
end
|
10
19
|
end
|
11
20
|
end
|
12
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graph-function
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Moore-Niemi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-10
|
12
|
+
date: 2016-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gnuplot
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: memory_profiler
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|