graph-function 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8156ac336aa21fcec58bb48b1a126a56858ef0a
4
- data.tar.gz: d3cac5ba48aa74d4454e93c0155713543052a33a
3
+ metadata.gz: db0cb7f4f328670b3e50c017aee8e7cb2e751b5e
4
+ data.tar.gz: 4dc1a476b53979628653cfc4ca8b58e2877a334c
5
5
  SHA512:
6
- metadata.gz: b3eee5a95f3524c98b31e2e563ab2d59ce3c525ce7a2ca95e0d21a0cecc42259122bd2b23be6365c741f6534a636d6722b9bb716db56b66d5e7c3258d518bdfe
7
- data.tar.gz: 8dd2d7be6cbbdaf401772dbbe293aa78a97952bf63da5ef69b1a382ded1f232a4d4e0b5143123b8adfcff1d68eec602c58eb327788be73ab5299586ba9ff0133
6
+ metadata.gz: a65c9b5017291a906b829a48e52f3026394c10d92291169316ab661a5e8cedf0c4318f15534037995c853aed191f9733fb259043c722db7e615f76205e7e69a3
7
+ data.tar.gz: 2494046e069fc639949a25d9ad3677ce5f8f81bac798229fe13423a6a71b5f58c55691ba8324490e50c17219d9585513055d31cfd13f8a0cc48cebaf92dcd1da
@@ -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 'benchmark-memory'
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'
@@ -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
- Benchmark.measure { f.call(data) }.real
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 (Graph::Function.configuration.trials == 1 ? 'execution time (seconds)' : 'average execution time (seconds)')
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
@@ -1,5 +1,5 @@
1
1
  module Graph
2
2
  module Function
3
- VERSION = '0.1.7'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  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.1.7
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-04 00:00:00.000000000 Z
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: benchmark-memory
71
+ name: memory_profiler
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="