spec/acceptance/benchmark.rb in solve-1.2.1 vs spec/acceptance/benchmark.rb in solve-2.0.0

- old
+ new

@@ -1,12 +1,14 @@ require 'benchmark' require 'solve' +require 'solve/gecode_solver' require File.expand_path("../large_graph_no_solution", __FILE__) require File.expand_path("../opscode_ci_graph", __FILE__) PROBLEM = OpscodeCiGraph -N = 1 +#PROBLEM = LargeGraphNoSolution +N = 100 def demands PROBLEM::DEMANDS end @@ -33,13 +35,25 @@ end STATIC_GRAPH = create_graph def solve_gecode - Solve::Solver.new(STATIC_GRAPH, demands, {}).resolve({}) -rescue Solve::Errors::NoSolutionError + Solve::GecodeSolver.new(STATIC_GRAPH, demands).resolve({}) +rescue Solve::Errors::NoSolutionError => e + # Uncomment to look at the error messages. Probably only useful if N == 1 + #puts e + e end +def solve_ruby + Solve::RubySolver.new(STATIC_GRAPH, demands).resolve({}) +rescue Solve::Errors::NoSolutionError => e + # Uncomment to look at the error messages. Probably only useful if N == 1 + #puts e + e +end + Benchmark.bm(12) do |x| x.report("Create graph") { N.times { create_graph } } x.report("Solve Gecode") { N.times { solve_gecode } } + x.report("Solve Ruby") { N.times { solve_ruby } } end