benchcc 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07b5d40f9fee0b3fb681ad158ad178b59f7c3836
4
- data.tar.gz: 5031ce36ea4b4019f516a1cc70f1a57a5f50585e
3
+ metadata.gz: 54612ab25b2af557fc641b9ccfaefcbc043ff5eb
4
+ data.tar.gz: ae13a4cbd526c90c51dc19f3db4e942903f5fc93
5
5
  SHA512:
6
- metadata.gz: 4598c095d3c2be82c288c45be30f8358bbf128e4d0ca21ec31cbbb4475ab8e58d30a1be3a04c6fe6c68c2631641eef26c88aa43abdd680db6fa9cee26a70bd27
7
- data.tar.gz: 0b4ba5c9acf0cecf64e09d48a5b32efbe14aa54315ba223e08c23fdbe9c2729ff11e244ba3ee276b0ba9273455473fae511cecad204a122dcc9b646d12413cbc
6
+ metadata.gz: b8ecedf598268b9173a0031521608bd5f8113a889790eab123281266b08611f046b448ce67f8f50edf0fa51d31d34cb8bf4671dcfc20ca00e4b32fd588dd4fe5
7
+ data.tar.gz: d6fe33c29a832ef6c1bf9e050d7bdd159a87e1d2ecc631dd856713cfcc545e85dc70be2c2e915162e593119cfad92e03dda5030095aa92f747fb4eab6d5d9666
data/benchcc.gemspec CHANGED
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency 'gnuplot', "~> 2.6"
21
21
  s.add_dependency 'rake', "~> 10.2"
22
22
  s.add_dependency 'ruby-progressbar', "~> 1.4"
23
- s.add_dependency 'tilt', '~> 2.0.1'
23
+ s.add_dependency 'tilt', '~> 2.0'
24
24
  end
@@ -20,19 +20,17 @@ module Benchcc
20
20
  end
21
21
  end
22
22
 
23
- def benchmark(file, envs, timeout: 10, relative_to: File.dirname(file), &block)
23
+ def benchmark(file, envs, timeout: 10, relative_to: File.dirname(file), stderr: $stderr, &block)
24
24
  progress = ProgressBar.create(format: "#{file} %p%% | %B |",
25
25
  total: envs.size)
26
- consecutive_errors, data = 0, []
26
+ data = []
27
27
  envs.each do |env|
28
- break if consecutive_errors >= 2
29
28
  code = Renderer.new(relative_to).render(file, **env)
30
29
  begin
31
30
  Timeout::timeout(timeout) { data << env.merge(block.call(code).to_h) }
32
- consecutive_errors = 0
33
31
  rescue CompilationError, Timeout::Error => e
34
- $stderr << e
35
- consecutive_errors += 1
32
+ stderr << e
33
+ break
36
34
  end
37
35
  progress.increment
38
36
  end
@@ -1,3 +1,3 @@
1
1
  module Benchcc
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -6,18 +6,18 @@ require 'timeout'
6
6
 
7
7
 
8
8
  describe Benchcc.method(:benchmark) do
9
- it('should ignore timeouts') {
9
+ it('should stop on timeout') {
10
10
  timeout = 0.3
11
- envs = [{time: timeout + 0.1}, {time: timeout - 0.1},
12
- {time: timeout + 0.2}, {time: timeout - 0.2}]
11
+ envs = [{time: timeout - 0.1}, {time: timeout + 0.1}, {time: timeout - 0.2}]
13
12
  Tempfile.create('') do |file|
14
- file.write('<%= time %>')
15
- file.flush
16
- data = Benchcc.benchmark(file.path, envs, timeout: timeout) do |code|
13
+ file.write('<%= time %>') && file.flush
14
+ devnull = File.open(File::NULL, 'w')
15
+
16
+ data = Benchcc.benchmark(file.path, envs, timeout: timeout, stderr: devnull) do |code|
17
17
  sleep(code.to_f)
18
18
  {time: code.to_f}
19
19
  end
20
- expect(data).to eq(envs.select { |env| env[:time] < timeout })
20
+ expect(data).to eq(envs.take_while { |env| env[:time] < timeout })
21
21
  end
22
22
  }
23
23
 
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.4
4
+ version: 0.0.5
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-07-06 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gnuplot
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.0.1
61
+ version: '2.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.0.1
68
+ version: '2.0'
69
69
  description: Benchcc is a collection of utilities to make easier the task of benchmarking
70
70
  C++ metaprograms
71
71
  email:
@@ -82,12 +82,6 @@ files:
82
82
  - Rakefile
83
83
  - benchcc.gemspec
84
84
  - benchmarks/Rakefile
85
- - benchmarks/fmap/_env.rb
86
- - benchmarks/fmap/_main.erb
87
- - benchmarks/fmap/hana_list.erb.cpp
88
- - benchmarks/fmap/mpl11_list.erb.cpp
89
- - benchmarks/fmap/mpl_list.erb.cpp
90
- - benchmarks/fmap/mpl_vector.erb.cpp
91
85
  - benchmarks/include/_env.rb
92
86
  - benchmarks/include/hana.erb.cpp
93
87
  - benchmarks/include/mpl.erb.cpp
@@ -97,16 +91,6 @@ files:
97
91
  - benchmarks/sum/_main.erb
98
92
  - benchmarks/sum/constexpr.erb.cpp
99
93
  - benchmarks/sum/mpl11_variadic_foldl.erb.cpp
100
- - benchmarks/tuple_create/_env.rb
101
- - benchmarks/tuple_create/boost_tuple.erb.cpp
102
- - benchmarks/tuple_create/fusion_tuple.erb.cpp
103
- - benchmarks/tuple_create/hana_list.erb.cpp
104
- - benchmarks/tuple_create/std_tuple.erb.cpp
105
- - benchmarks/tuple_last/_env.rb
106
- - benchmarks/tuple_last/boost_tuple.erb.cpp
107
- - benchmarks/tuple_last/fusion_tuple.erb.cpp
108
- - benchmarks/tuple_last/hana_list.erb.cpp
109
- - benchmarks/tuple_last/std_tuple.erb.cpp
110
94
  - benchmarks/type_foldl/_env.rb
111
95
  - benchmarks/type_foldl/_main.erb
112
96
  - benchmarks/type_foldl/hana_list.erb.cpp
@@ -114,12 +98,6 @@ files:
114
98
  - benchmarks/type_foldl/mpl11_list.erb.cpp
115
99
  - benchmarks/type_foldl/mpl_list.erb.cpp
116
100
  - benchmarks/type_foldl/mpl_vector.erb.cpp
117
- - benchmarks/value_foldl/_env.rb
118
- - benchmarks/value_foldl/_main.erb
119
- - benchmarks/value_foldl/fusion_cons.erb.cpp
120
- - benchmarks/value_foldl/fusion_list.erb.cpp
121
- - benchmarks/value_foldl/fusion_vector.erb.cpp
122
- - benchmarks/value_foldl/hana_list.erb.cpp
123
101
  - lib/benchcc.rb
124
102
  - lib/benchcc/benchmark.rb
125
103
  - lib/benchcc/compiler.rb
@@ -1,3 +0,0 @@
1
- (0...1000).map { |depth|
2
- { breadth: 1, depth: depth }
3
- }
@@ -1,7 +0,0 @@
1
- <%= (0...breadth).map { |breadth|
2
- xs = (0...depth).map { |depth| "x#{breadth}<#{depth}>" }
3
- <<-EOS
4
- template <int> struct x#{breadth} { using type = x#{breadth}; };
5
- #{yield xs, breadth, depth}
6
- EOS
7
- }.join("\n") %>
@@ -1,18 +0,0 @@
1
- #include <boost/hana/list.hpp>
2
-
3
-
4
- template <typename X>
5
- struct _f { };
6
-
7
- constexpr struct {
8
- template <typename X>
9
- constexpr _f<X> operator()(X) const;
10
- } f{};
11
-
12
- <%=
13
- render('_main.erb') do |xs, breadth, depth|
14
- xs = xs.map { |x| "#{x}{}" }.join(', ')
15
- list = "boost::hana::list(#{xs})"
16
- "static const auto go#{breadth} = boost::hana::fmap(f, #{list});"
17
- end
18
- %>
@@ -1,15 +0,0 @@
1
- #include <boost/mpl11/list.hpp>
2
-
3
-
4
- struct f {
5
- using type = f;
6
- template <typename>
7
- struct apply { struct type; };
8
- };
9
-
10
- <%=
11
- render('_main.erb') do |xs, breadth, depth|
12
- list = "boost::mpl11::list<#{xs.join(', ')}>"
13
- "using go#{breadth} = boost::mpl11::fmap<f, #{list}>::type;"
14
- end
15
- %>
@@ -1,15 +0,0 @@
1
- #include <boost/mpl/transform.hpp>
2
- <%= Benchcc::MPL::List.new(0...depth).includes %>
3
-
4
-
5
- struct f {
6
- template <typename>
7
- struct apply { struct type; };
8
- };
9
-
10
- <%=
11
- render('_main.erb') do |xs, breadth, depth|
12
- list = Benchcc::MPL::List.new(xs)
13
- "using go#{breadth} = boost::mpl::transform<#{list}, f>::type;"
14
- end
15
- %>
@@ -1,15 +0,0 @@
1
- #include <boost/mpl/transform.hpp>
2
- <%= Benchcc::MPL::Vector.new(0...depth).includes %>
3
-
4
-
5
- struct f {
6
- template <typename>
7
- struct apply { struct type; };
8
- };
9
-
10
- <%=
11
- render('_main.erb') do |xs, breadth, depth|
12
- vector = Benchcc::MPL::Vector.new(xs)
13
- "using go#{breadth} = boost::mpl::transform<#{vector}, f>::type;"
14
- end
15
- %>
@@ -1,3 +0,0 @@
1
- (0...1000).map { |depth|
2
- { depth: depth }
3
- }
@@ -1,6 +0,0 @@
1
- #include <boost/tuple/tuple.hpp>
2
-
3
-
4
- int main() {
5
- auto go = boost::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
- }
@@ -1,6 +0,0 @@
1
- #include <boost/fusion/tuple.hpp>
2
-
3
-
4
- int main() {
5
- auto go = boost::fusion::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
- }
@@ -1,6 +0,0 @@
1
- #include <boost/hana/list.hpp>
2
-
3
-
4
- int main() {
5
- auto go = boost::hana::list(<%= (0...depth).to_a.join(', ') %>);
6
- }
@@ -1,6 +0,0 @@
1
- #include <tuple>
2
-
3
-
4
- int main() {
5
- auto go = std::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
- }
@@ -1,3 +0,0 @@
1
- (1...1000).map { |depth|
2
- { depth: depth }
3
- }
@@ -1,7 +0,0 @@
1
- #include <boost/tuple/tuple.hpp>
2
-
3
-
4
- int main() {
5
- auto go = boost::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
- auto last = boost::get< <%= depth - 1 %> >(go);
7
- }
@@ -1,7 +0,0 @@
1
- #include <boost/fusion/tuple.hpp>
2
-
3
-
4
- int main() {
5
- auto go = boost::fusion::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
- auto last = boost::fusion::get< <%= depth - 1 %> >(go);
7
- }
@@ -1,7 +0,0 @@
1
- #include <boost/hana/list.hpp>
2
-
3
-
4
- int main() {
5
- auto go = boost::hana::list(<%= (0...depth).to_a.join(', ') %>);
6
- auto last = boost::hana::at(boost::hana::size_t< <%= depth - 1 %> >, go);
7
- }
@@ -1,7 +0,0 @@
1
- #include <tuple>
2
-
3
-
4
- int main() {
5
- auto go = std::make_tuple(<%= (0...depth).to_a.join(', ') %>);
6
- auto last = std::get< <%= depth - 1 %> >(go);
7
- }
@@ -1,3 +0,0 @@
1
- (0..1000).step(5).map { |depth|
2
- { breadth: 1, depth: depth }
3
- }
@@ -1,17 +0,0 @@
1
- template <typename ...>
2
- struct result { };
3
-
4
- constexpr struct {
5
- template <typename State, typename X>
6
- constexpr result<State, X> operator()(State, X) const
7
- { return {}; }
8
- } f{};
9
-
10
- <%= (0...breadth).map { |breadth|
11
- xs = (0...depth).map { |depth| "x#{breadth}<#{depth}>" }
12
- <<-EOS
13
- constexpr struct { } state#{breadth}{};
14
- template <int> struct x#{breadth} { };
15
- static const auto go#{breadth} = #{yield 'f', "state#{breadth}", xs};
16
- EOS
17
- }.join("\n") %>
@@ -1,8 +0,0 @@
1
- #include <boost/fusion/algorithm/iteration/fold.hpp>
2
- <%= Benchcc::Fusion::Cons.new(0...depth).includes %>
3
-
4
-
5
- <%= render('_main.erb') do |f, state, xs|
6
- cons = Benchcc::Fusion::Cons.new(xs)
7
- "boost::fusion::fold(#{cons}{}, #{state}, #{f})"
8
- end %>
@@ -1,9 +0,0 @@
1
- <%= Benchcc::Fusion::List.new(0...depth).includes %>
2
-
3
- #include <boost/fusion/algorithm/iteration/fold.hpp>
4
-
5
-
6
- <%= render('_main.erb') do |f, state, xs|
7
- list = Benchcc::Fusion::List.new(xs)
8
- "boost::fusion::fold(#{list}{}, #{state}, #{f})"
9
- end %>
@@ -1,9 +0,0 @@
1
- <%= Benchcc::Fusion::Vector.new(0...depth).includes %>
2
-
3
- #include <boost/fusion/algorithm/iteration/fold.hpp>
4
-
5
-
6
- <%= render('_main.erb') do |f, state, xs|
7
- vector = Benchcc::Fusion::Vector.new(xs)
8
- "boost::fusion::fold(#{vector}{}, #{state}, #{f})"
9
- end %>
@@ -1,6 +0,0 @@
1
- #include <boost/hana/list.hpp>
2
-
3
- <%= render('_main.erb') do |f, state, xs|
4
- xs = xs.map { |x| "#{x}{}" }.join(', ')
5
- "boost::hana::foldl(#{f}, #{state}, boost::hana::list(#{xs}))"
6
- end %>