benchcc 0.0.16 → 0.0.17

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: c7748c9c22e06d6b849fe2b2bcbfb0b656da2d86
4
- data.tar.gz: f16027a06f20dd5f994c5c64935c2acdc4dae328
3
+ metadata.gz: 3bb8d387e7a5f6c86297ad57e1e8cef520ded506
4
+ data.tar.gz: 0693559053329ba387136023760b898bec78af3e
5
5
  SHA512:
6
- metadata.gz: cf8617a11e5eae06eefa8f77579373d74edb09fa34a5a8d2d481edc41da1c75e2db5077ab35c384b51460bbb84ccccfbfaff2bc10f887c8380982e80fbbf7dca
7
- data.tar.gz: c3cbc63365ebfe9b75b7a9169f99fdbb4eb332dc3328bc597c27c2289d051d36a80fc03371f4b2c62213d51c4f04f191e62ac0ef2794ad20ea23188539e3c3f8
6
+ metadata.gz: 8c8bd11227604ebf4b60c99c3d3c8a2bfb69149c2f8d30541a62a456a3ea58e823a402882ade758b78567ebedb385d849ccd84b6b7131578624e7914846a24d1
7
+ data.tar.gz: 8548773c56e151949d22450a9feda4726e562cae055bbfe9f21b32a4d8545458c4cacda482a7b6850b92b73a9ee6294b60831b47c4774255e1b5a74e63732c84
@@ -57,12 +57,18 @@ module Benchcc
57
57
  )
58
58
  end
59
59
 
60
- csv << row
61
- rescue ExecutionError, CompilationError, Timeout::Error => e
60
+ rescue CompilationError, CompilationTimeout => e
62
61
  $stderr << e
63
62
  break
63
+
64
+ rescue ExecutionError, ExecutionTimeout => e
65
+ $stderr << e
66
+ break unless features.include?(:compilation_time) || features.include?(:memory_usage)
67
+
68
+ ensure
69
+ csv << row
70
+ progress.increment
64
71
  end
65
- progress.increment
66
72
  end
67
73
  end
68
74
  return data
@@ -10,9 +10,15 @@ module Benchcc
10
10
  class CompilationError < RuntimeError
11
11
  end
12
12
 
13
+ class CompilationTimeout < RuntimeError
14
+ end
15
+
13
16
  class ExecutionError < RuntimeError
14
17
  end
15
18
 
19
+ class ExecutionTimeout < RuntimeError
20
+ end
21
+
16
22
  class Clang
17
23
  def call(input_file:, features:, compiler_executable:, compiler_options:,
18
24
  compilation_timeout:, execution_timeout:)
@@ -34,7 +40,7 @@ module Benchcc
34
40
  end
35
41
 
36
42
  command = "#{compiler_executable} #{compiler_options.join(' ')} #{input_file}"
37
- stdout, stderr, status = Timeout::timeout(compilation_timeout) {
43
+ stdout, stderr, status = Timeout::timeout(compilation_timeout, CompilationTimeout) {
38
44
  Open3.capture3(command)
39
45
  }
40
46
 
@@ -77,7 +83,7 @@ module Benchcc
77
83
 
78
84
  if features.include?(:execution_time)
79
85
  command = "#{tmp_dir}/a.out"
80
- stdout, stderr, status = Timeout::timeout(execution_timeout) {
86
+ stdout, stderr, status = Timeout::timeout(execution_timeout, ExecutionTimeout) {
81
87
  Open3.capture3(command)
82
88
  }
83
89
  if status.success?
data/lib/benchcc/plot.rb CHANGED
@@ -46,7 +46,19 @@ module Benchcc
46
46
  plot.output output
47
47
  plot.data = curves.map { |curve|
48
48
  csv = CSV.table(curve[:input])
49
- Gnuplot::DataSet.new([csv[x_feature], csv[y_feature]]) { |ds|
49
+ ys = csv[y_feature]
50
+ xs = csv[x_feature]
51
+
52
+ # Remove trailing nils from the y-axis. nils can arise when e.g.
53
+ # runtime execution failed but we still kept on gathering info
54
+ # for the compilation, so the execution_time column has some
55
+ # trailing empty values.
56
+ ys.pop until ys.last
57
+
58
+ # Restrict the x-axis to the number of valid y-axis values.
59
+ xs = xs[0...ys.size]
60
+
61
+ Gnuplot::DataSet.new([xs, ys]) { |ds|
50
62
  ds.title = curve[:title]
51
63
  ds.with = 'lines'
52
64
  }
@@ -1,3 +1,3 @@
1
1
  module Benchcc
2
- VERSION = "0.0.16"
2
+ VERSION = "0.0.17"
3
3
  end
data/spec/plot_spec.rb CHANGED
@@ -9,6 +9,7 @@ describe 'plots' do
9
9
  @tmpdir = Dir.mktmpdir
10
10
  @out = File.join(@tmpdir, 'plot.png')
11
11
  @csv = Pathname.new('src/plot.csv').expand_path(File.dirname(__FILE__))
12
+ @partial_csv = Pathname.new('src/partial_plot.csv').expand_path(File.dirname(__FILE__))
12
13
  end
13
14
 
14
15
  after :each do
@@ -17,12 +18,19 @@ describe 'plots' do
17
18
 
18
19
  describe Benchcc.method(:plot) do
19
20
  Benchcc::Y_FEATURES.each do |feature|
20
- it {
21
+ it ("does not explode") {
21
22
  curves = [{title: 'curve title', input: @csv}]
22
23
  expect {
23
24
  Benchcc.plot('plot title', @out, curves, y_feature: feature)
24
25
  }.not_to raise_error
25
26
  }
27
+
28
+ it ("does not explode when points are missing") {
29
+ curves = [{title: 'curve title', input: @partial_csv}]
30
+ expect {
31
+ Benchcc.plot('plot title', @out, curves, y_feature: feature)
32
+ }.not_to raise_error
33
+ }
26
34
  end
27
35
  end
28
36
  end
data/spec/src/plot.csv CHANGED
@@ -1,3 +1,31 @@
1
- input_size, memory_usage, compilation_time, run_time
2
- 1, 2, 3, 4
3
- 5, 6, 7, 8
1
+ input_size,compilation_time,execution_time,memory_usage
2
+ 1,0.8664,145,41852928
3
+ 2,0.8108,292,42033152
4
+ 3,0.8633,444,42160128
5
+ 4,0.8075,583,42364928
6
+ 5,0.8311,738,42688512
7
+ 6,0.8262,903,43081728
8
+ 7,0.9357,1041,43544576
9
+ 8,0.9197,1290,44019712
10
+ 9,0.9823,1341,43995136
11
+ 10,0.9425,1473,44441600
12
+ 11,1.0235,1636,44896256
13
+ 12,0.9284,1765,45076480
14
+ 13,0.9273,1973,45666304
15
+ 14,1.0337,2087,45592576
16
+ 15,1.0129,2210,46215168
17
+ 16,0.9669,2372,46510080
18
+ 17,1.0574,2545,46915584
19
+ 18,1.0452,2647,46895104
20
+ 19,1.0269,2814,47517696
21
+ 20,1.0387,2971,47865856
22
+ 21,1.0649,3664,48504832
23
+ 22,1.3542,3469,48812032
24
+ 23,1.5643,3488,49229824
25
+ 24,1.1309,3568,49364992
26
+ 25,1.1786,3774,49541120
27
+ 26,1.5452,4005,50216960
28
+ 27,1.2139,3989,50528256
29
+ 28,1.1758,4208,51191808
30
+ 29,1.2415,4343,51441664
31
+ 30,1.3232,4472,51580928
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchcc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Dionne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-29 00:00:00.000000000 Z
11
+ date: 2014-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gnuplot