mirror of https://github.com/CGAL/cgal
Added the ability to select kernel when running benchmarks
This commit is contained in:
parent
93060c6649
commit
8757d4ac07
|
|
@ -6,7 +6,7 @@ class TestConfig:
|
||||||
Describes a benchmark test case to run over a set of models
|
Describes a benchmark test case to run over a set of models
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, testName, testModels, numTrials, numSources, numQueries, randSeed):
|
def __init__(self, testName, testModels, numTrials, numSources, numQueries, randSeed, kernel="epick"):
|
||||||
"""
|
"""
|
||||||
testName - the name of the test as it should appear in the documentation file
|
testName - the name of the test as it should appear in the documentation file
|
||||||
testModels - a list of .off model files to run the test on
|
testModels - a list of .off model files to run the test on
|
||||||
|
|
@ -21,9 +21,10 @@ class TestConfig:
|
||||||
self.numSources = numSources;
|
self.numSources = numSources;
|
||||||
self.numQueries = numQueries;
|
self.numQueries = numQueries;
|
||||||
self.randSeed = randSeed;
|
self.randSeed = randSeed;
|
||||||
|
self.kernel = kernel;
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s : #Trials = %d, #Sources = %d, #Queries = %d" % (self.testName, self.numTrials, self.numSources, self.numQueries);
|
return "%s : Kernel = %s #Trials = %d, #Sources = %d, #Queries = %d" % (self.testName, self.kernel, self.numTrials, self.numSources, self.numQueries);
|
||||||
|
|
||||||
def read_all_lines(file):
|
def read_all_lines(file):
|
||||||
f = open(file, "r");
|
f = open(file, "r");
|
||||||
|
|
@ -55,7 +56,7 @@ def run_benchmarks(testConfig, outputFile):
|
||||||
for model in testConfig.testModels:
|
for model in testConfig.testModels:
|
||||||
sys.stdout.write("Model = %s ... " % model);
|
sys.stdout.write("Model = %s ... " % model);
|
||||||
sys.stdout.flush();
|
sys.stdout.flush();
|
||||||
result = subprocess.call(['./benchmark_shortest_paths.exe', '-p', model.strip(), '-r', str(testConfig.randSeed), '-t', str(testConfig.numTrials), '-n', str(testConfig.numSources), '-q', str(testConfig.numQueries)], stdout=outputFile);
|
result = subprocess.call(['./benchmark_shortest_paths.exe', '-k', testConfig.kernel, '-p', model.strip(), '-r', str(testConfig.randSeed), '-t', str(testConfig.numTrials), '-n', str(testConfig.numSources), '-q', str(testConfig.numQueries)], stdout=outputFile);
|
||||||
if result == 0:
|
if result == 0:
|
||||||
sys.stdout.write("Done.\n");
|
sys.stdout.write("Done.\n");
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,42 @@
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
#include <boost/program_options.hpp>
|
||||||
|
#include <boost/timer/timer.hpp>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include <CGAL/Random.h>
|
#include <CGAL/Random.h>
|
||||||
|
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
#include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
|
||||||
|
#include <CGAL/Simple_cartesian.h>
|
||||||
|
|
||||||
#include <CGAL/Polyhedron_3.h>
|
#include <CGAL/Polyhedron_3.h>
|
||||||
#include <CGAL/Polyhedron_items_with_id_3.h>
|
#include <CGAL/Polyhedron_items_with_id_3.h>
|
||||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||||
|
|
||||||
#include <CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits.h>
|
|
||||||
#include <CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h>
|
|
||||||
|
|
||||||
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
||||||
#include <CGAL/boost/graph/iterator.h>
|
#include <CGAL/boost/graph/iterator.h>
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path_traits.h>
|
||||||
#include <boost/timer/timer.hpp>
|
#include <CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#define UNUSED(X) (void)sizeof(X)
|
#define UNUSED(X) (void)sizeof(X)
|
||||||
|
|
||||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
namespace po = boost::program_options;
|
||||||
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron_3;
|
|
||||||
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Polyhedron_3> Traits;
|
|
||||||
typedef Traits::Barycentric_coordinate Barycentric_coordinate;
|
|
||||||
typedef Traits::Construct_barycentric_coordinate Construct_barycentric_coordinate;
|
|
||||||
typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;
|
|
||||||
typedef boost::graph_traits<Polyhedron_3> GraphTraits;
|
|
||||||
typedef GraphTraits::vertex_descriptor vertex_descriptor;
|
|
||||||
typedef GraphTraits::vertex_iterator vertex_iterator;
|
|
||||||
typedef GraphTraits::halfedge_descriptor halfedge_descriptor;
|
|
||||||
typedef GraphTraits::halfedge_iterator halfedge_iterator;
|
|
||||||
typedef GraphTraits::face_descriptor face_descriptor;
|
|
||||||
typedef GraphTraits::face_iterator face_iterator;
|
|
||||||
|
|
||||||
|
|
||||||
typedef boost::timer::nanosecond_type nanosecond_type;
|
typedef boost::timer::nanosecond_type nanosecond_type;
|
||||||
|
|
||||||
|
enum Kernel_type
|
||||||
|
{
|
||||||
|
KERNEL_UNKNOWN,
|
||||||
|
KERNEL_IPICK,
|
||||||
|
KERNEL_EPICK,
|
||||||
|
KERNEL_EPECK,
|
||||||
|
};
|
||||||
|
|
||||||
template <class IntType>
|
template <class IntType>
|
||||||
class SampledValue
|
class SampledValue
|
||||||
{
|
{
|
||||||
|
|
@ -148,16 +147,43 @@ void print_results(std::ostream& stream, const std::string& filename, const Benc
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Barycentric_coordinate random_coordinate(CGAL::Random& rand)
|
template <class Traits>
|
||||||
|
typename Traits::Barycentric_coordinate random_coordinate(CGAL::Random& rand)
|
||||||
{
|
{
|
||||||
Construct_barycentric_coordinate construct_barycentric_coordinate;
|
typedef typename Traits::FT FT;
|
||||||
Traits::FT u = rand.uniform_01<Traits::FT>();
|
typename Traits::Construct_barycentric_coordinate construct_barycentric_coordinate;
|
||||||
Traits::FT v = rand.uniform_real(Traits::FT(0.0), Traits::FT(1.0) - u);
|
FT u = rand.uniform_real(FT(0.0), FT(1.0));
|
||||||
return construct_barycentric_coordinate(u, v, Traits::FT(1.0) - u - v);
|
FT v = rand.uniform_real(FT(0.0), FT(1.0) - u);
|
||||||
|
return construct_barycentric_coordinate(u, v, FT(1.0) - u - v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_benchmarks(CGAL::Random& rand, size_t numTrials, size_t numSources, size_t numQueries, Polyhedron_3& polyhedron, Benchmark_data& outData)
|
template <class Kernel>
|
||||||
|
void run_benchmarks(CGAL::Random& rand, size_t numTrials, size_t numSources, size_t numQueries, const std::string& polyhedronFile, Benchmark_data& outData)
|
||||||
{
|
{
|
||||||
|
typedef CGAL::Polyhedron_3<Kernel, CGAL::Polyhedron_items_with_id_3> Polyhedron_3;
|
||||||
|
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Polyhedron_3> Traits;
|
||||||
|
typedef typename Traits::Barycentric_coordinate Barycentric_coordinate;
|
||||||
|
typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;
|
||||||
|
typedef typename Surface_mesh_shortest_path::Face_location Face_location;
|
||||||
|
typedef typename Surface_mesh_shortest_path::FT FT;
|
||||||
|
typedef boost::graph_traits<Polyhedron_3> GraphTraits;
|
||||||
|
typedef typename GraphTraits::face_descriptor face_descriptor;
|
||||||
|
typedef typename GraphTraits::face_iterator face_iterator;
|
||||||
|
|
||||||
|
std::ifstream inFile(polyhedronFile.c_str());
|
||||||
|
|
||||||
|
if (!inFile)
|
||||||
|
{
|
||||||
|
throw std::runtime_error(std::string("Model file \"") + polyhedronFile + std::string("\" does not exist."));
|
||||||
|
}
|
||||||
|
|
||||||
|
Polyhedron_3 polyhedron;
|
||||||
|
|
||||||
|
inFile >> polyhedron;
|
||||||
|
inFile.close();
|
||||||
|
|
||||||
|
CGAL::set_halfedgeds_items_id(polyhedron);
|
||||||
|
|
||||||
boost::timer::cpu_timer timer;
|
boost::timer::cpu_timer timer;
|
||||||
outData.reset();
|
outData.reset();
|
||||||
|
|
||||||
|
|
@ -180,13 +206,13 @@ void run_benchmarks(CGAL::Random& rand, size_t numTrials, size_t numSources, siz
|
||||||
|
|
||||||
for (size_t i = 0; i < numTrials; ++i)
|
for (size_t i = 0; i < numTrials; ++i)
|
||||||
{
|
{
|
||||||
std::vector<Surface_mesh_shortest_path::Face_location> sourcePoints;
|
std::vector<Face_location> sourcePoints;
|
||||||
|
|
||||||
while (sourcePoints.size() < numSources)
|
while (sourcePoints.size() < numSources)
|
||||||
{
|
{
|
||||||
face_descriptor sourceFace = allFaces[rand.get_int(0, allFaces.size())];
|
face_descriptor sourceFace = allFaces[rand.get_int(0, allFaces.size())];
|
||||||
Barycentric_coordinate sourceLocation = random_coordinate(rand);
|
Barycentric_coordinate sourceLocation = random_coordinate<Traits>(rand);
|
||||||
sourcePoints.push_back(Surface_mesh_shortest_path::Face_location(sourceFace, sourceLocation));
|
sourcePoints.push_back(Face_location(sourceFace, sourceLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
@ -204,10 +230,10 @@ void run_benchmarks(CGAL::Random& rand, size_t numTrials, size_t numSources, siz
|
||||||
for (size_t j = 0; j < numQueries; ++j)
|
for (size_t j = 0; j < numQueries; ++j)
|
||||||
{
|
{
|
||||||
face_descriptor sourceFace = allFaces[rand.get_int(0, allFaces.size())];
|
face_descriptor sourceFace = allFaces[rand.get_int(0, allFaces.size())];
|
||||||
Barycentric_coordinate sourceLocation = random_coordinate(rand);
|
Barycentric_coordinate sourceLocation = random_coordinate<Traits>(rand);
|
||||||
|
|
||||||
timer.start();
|
timer.start();
|
||||||
Traits::FT distance = shortestPaths.shortest_distance_to_source_points(sourceFace, sourceLocation).first;
|
FT distance = shortestPaths.shortest_distance_to_source_points(sourceFace, sourceLocation).first;
|
||||||
timer.stop();
|
timer.stop();
|
||||||
UNUSED(distance);
|
UNUSED(distance);
|
||||||
|
|
||||||
|
|
@ -218,6 +244,26 @@ void run_benchmarks(CGAL::Random& rand, size_t numTrials, size_t numSources, siz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kernel_type parse_kernel_type(const std::string& s)
|
||||||
|
{
|
||||||
|
if (boost::iequals(s, "ipick"))
|
||||||
|
{
|
||||||
|
return KERNEL_IPICK;
|
||||||
|
}
|
||||||
|
else if (boost::iequals(s, "epick"))
|
||||||
|
{
|
||||||
|
return KERNEL_EPICK;
|
||||||
|
}
|
||||||
|
else if (boost::iequals(s, "epeck"))
|
||||||
|
{
|
||||||
|
return KERNEL_EPECK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return KERNEL_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
|
|
@ -227,9 +273,10 @@ int main(int argc, char* argv[])
|
||||||
("help,h", "Display help message")
|
("help,h", "Display help message")
|
||||||
("polyhedron,p", po::value<std::string>(), "Polyhedron input file")
|
("polyhedron,p", po::value<std::string>(), "Polyhedron input file")
|
||||||
("randomseed,r", po::value<size_t>()->default_value(0), "Randomization seed value")
|
("randomseed,r", po::value<size_t>()->default_value(0), "Randomization seed value")
|
||||||
("trials,t", po::value<size_t>()->default_value(10), "Number of trials to run")
|
("trials,t", po::value<size_t>()->default_value(20), "Number of trials to run")
|
||||||
("numpoints,n", po::value<size_t>()->default_value(10), "Number of source points per trial")
|
("numpoints,n", po::value<size_t>()->default_value(1), "Number of source points per trial")
|
||||||
("queries,q", po::value<size_t>()->default_value(10), "Number of queries to run per trial")
|
("queries,q", po::value<size_t>()->default_value(100), "Number of queries to run per trial")
|
||||||
|
("kernel,k", po::value<std::string>()->default_value("epick"), "Kernel to use. One of \'ipick\', \'epick\', \'epeck\'")
|
||||||
;
|
;
|
||||||
|
|
||||||
po::variables_map vm;
|
po::variables_map vm;
|
||||||
|
|
@ -242,34 +289,39 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
else if (vm.count("polyhedron"))
|
else if (vm.count("polyhedron"))
|
||||||
{
|
{
|
||||||
Polyhedron_3 polyhedron;
|
|
||||||
|
|
||||||
std::ifstream inFile(vm["polyhedron"].as<std::string>().c_str());
|
|
||||||
|
|
||||||
if (!inFile)
|
|
||||||
{
|
|
||||||
std::cout << "Model file \"" << vm["polyhedron"].as<std::string>().c_str() << "\" does not exist." << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inFile >> polyhedron;
|
|
||||||
inFile.close();
|
|
||||||
|
|
||||||
CGAL::set_halfedgeds_items_id(polyhedron);
|
|
||||||
|
|
||||||
Benchmark_data results;
|
Benchmark_data results;
|
||||||
|
|
||||||
CGAL::Random rand(vm["randomseed"].as<size_t>());
|
CGAL::Random rand(vm["randomseed"].as<size_t>());
|
||||||
|
size_t numTrials = vm["trials"].as<size_t>();
|
||||||
|
size_t numPoints = vm["numpoints"].as<size_t>();
|
||||||
|
size_t numQueries = vm["queries"].as<size_t>();
|
||||||
|
std::string polyhedronFile = vm["polyhedron"].as<std::string>();
|
||||||
|
|
||||||
run_benchmarks(
|
try
|
||||||
rand,
|
{
|
||||||
vm["trials"].as<size_t>(),
|
switch (parse_kernel_type(vm["kernel"].as<std::string>()))
|
||||||
vm["numpoints"].as<size_t>(),
|
{
|
||||||
vm["queries"].as<size_t>(),
|
case KERNEL_IPICK:
|
||||||
polyhedron,
|
run_benchmarks<CGAL::Simple_cartesian<double> >(rand, numTrials, numPoints, numQueries, polyhedronFile, results);
|
||||||
results);
|
break;
|
||||||
|
case KERNEL_EPICK:
|
||||||
|
run_benchmarks<CGAL::Exact_predicates_inexact_constructions_kernel>(rand, numTrials, numPoints, numQueries, polyhedronFile, results);
|
||||||
|
break;
|
||||||
|
case KERNEL_EPECK:
|
||||||
|
run_benchmarks<CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt>(rand, numTrials, numPoints, numQueries, polyhedronFile, results);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cerr << "Invalid kernel type: \"" << vm["kernel"].as<std::string>() << "\"" << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
std::cerr << "Runtime error: " << e.what() << std::endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
print_results(std::cout, vm["polyhedron"].as<std::string>(), results);
|
print_results(std::cout, polyhedronFile, results);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import random;
|
||||||
import re;
|
import re;
|
||||||
import benchmark;
|
import benchmark;
|
||||||
import os;
|
import os;
|
||||||
|
import argparse;
|
||||||
|
|
||||||
def make_table_file_name(tableFileBase, numSources):
|
def make_table_file_name(tableFileBase, numSources):
|
||||||
return tableFileBase + '_' + str(numSources) + ".txt";
|
return tableFileBase + '_' + str(numSources) + ".txt";
|
||||||
|
|
@ -37,7 +38,7 @@ def make_figure_file_name(figureFileBase, modelFile):
|
||||||
|
|
||||||
def print_to_datafiles(config, dataFileName, modelInfo):
|
def print_to_datafiles(config, dataFileName, modelInfo):
|
||||||
file = open(dataFileName, "a");
|
file = open(dataFileName, "a");
|
||||||
file.write("%d %d %s %s %s\n" % (config.numSources, modelInfo.get("num vertices", 0), modelInfo.get('construction', '0'), modelInfo.get('query', '0'), modelInfo.get('memory (peak)', '0')));
|
file.write("%d %d %s %s %s\n" % (config.numSources, int(modelInfo.get("num vertices", 0)), modelInfo.get('construction', '0'), modelInfo.get('query', '0'), modelInfo.get('memory (peak)', '0')));
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
def print_table(infoSet, config, outFile):
|
def print_table(infoSet, config, outFile):
|
||||||
|
|
@ -55,32 +56,73 @@ def print_table(infoSet, config, outFile):
|
||||||
outFile.write("</center>\n");
|
outFile.write("</center>\n");
|
||||||
outFile.write('\n');
|
outFile.write('\n');
|
||||||
|
|
||||||
# Specify a file to output to, and optionally a random seed to ensure consistent tests are run
|
parser = argparse.ArgumentParser(description="Run benchmarks on multiple model files");
|
||||||
if len(sys.argv) <= 5:
|
|
||||||
print("Usage: python %s <modelsFile> <dataFileBase> <tableFileBase> <figureFileBase> <randomseed>" % sys.argv[0]);
|
|
||||||
sys.exit(0);
|
|
||||||
|
|
||||||
sampleRange = reversed([1] + list(range(5, 55, 5)));
|
parser.add_argument('-r', '--range', type=str, default=['1'], nargs='*', help="Can specify multiple single values, or ranges. Format is '#' or '#,#' or '#,#,#' for a single value, a range of values, or a range values of values with a specified skip");
|
||||||
|
parser.add_argument('-f', '--modelsfile', '--modelsfiles', type=str, nargs='*', help="a file containing a list of models to test on, one per line");
|
||||||
|
parser.add_argument('-m', '--model', '--models', type=str, nargs='*');
|
||||||
|
parser.add_argument('-s', '--randseed', type=int, help="Random seed for tests.");
|
||||||
|
parser.add_argument('-d', '--datafilebase', type=str, default='_modeldata', help="Base name for temporary data files (existing files will be overwritten).");
|
||||||
|
parser.add_argument('-t', '--tablefilebase', type=str, help="Base name for generated user manual tables (will be of the form \"<tablefilebase>_#.txt\", leave blank to suppress generation)");
|
||||||
|
parser.add_argument('-o', '--plotfilebase', type=str, help="Base name for generated plot figures (will be of the form \"<plotfilebase>_<modelname>.png\", leave blank to suppress generation)");
|
||||||
|
parser.add_argument('-k', '--kernel', choices=['ipick', 'epick', 'epeck'], default='epick', help="Geometry kernel to use for the benchmark.");
|
||||||
|
|
||||||
testModels = benchmark.read_all_lines(sys.argv[1]);
|
programArgs = parser.parse_args();
|
||||||
|
|
||||||
if not benchmark.prepare_program():
|
setOfSamples = set();
|
||||||
|
|
||||||
|
if programArgs.range:
|
||||||
|
for r in programArgs.range:
|
||||||
|
toks = r.split(',');
|
||||||
|
if len(toks) == 1:
|
||||||
|
setOfSamples.add(int(toks[0]));
|
||||||
|
elif len(toks) == 2:
|
||||||
|
setOfSamples.update(range(int(toks[0]), int(toks[1])));
|
||||||
|
elif len(toks) == 3:
|
||||||
|
setOfSamples.update(range(int(toks[0]), int(toks[1]), int(toks[2])));
|
||||||
|
else:
|
||||||
|
raise "Invalid range: " + r;
|
||||||
|
|
||||||
|
sampleRange = reversed(sorted(list(setOfSamples)));
|
||||||
|
|
||||||
|
testModels = [];
|
||||||
|
|
||||||
|
if programArgs.modelsfile:
|
||||||
|
for modelsFile in programArgs.modelsfile:
|
||||||
|
testModels.extend(benchmark.read_all_lines(modelsFile));
|
||||||
|
|
||||||
|
if programArgs.model:
|
||||||
|
for model in programArgs.model:
|
||||||
|
testModels.append(model);
|
||||||
|
|
||||||
|
if len(testModels) == 0:
|
||||||
|
print("Error, must specify at least one model to benchmark");
|
||||||
sys.exit(1);
|
sys.exit(1);
|
||||||
|
|
||||||
rand = random.Random(int(sys.argv[5]));
|
rand = random.Random(programArgs.randseed);
|
||||||
|
|
||||||
dataFileBase = sys.argv[2];
|
dataFileBase = programArgs.datafilebase;
|
||||||
tableFileBase = sys.argv[3];
|
tableFileBase = programArgs.tablefilebase;
|
||||||
figureFileBase = sys.argv[4];
|
plotFileBase = programArgs.plotfilebase;
|
||||||
|
|
||||||
|
kernel = programArgs.kernel;
|
||||||
|
|
||||||
|
if tableFileBase == None and plotFileBase == None:
|
||||||
|
print("Error, must specify either a table output or figure output file");
|
||||||
|
sys.exit(1);
|
||||||
|
|
||||||
|
if not benchmark.prepare_program():
|
||||||
|
print("Error, could not compile program");
|
||||||
|
sys.exit(1);
|
||||||
|
|
||||||
for model in testModels:
|
for model in testModels:
|
||||||
modelFileName = make_model_data_file_name(dataFileBase, model);
|
modelDataFileName = make_model_data_file_name(dataFileBase, model);
|
||||||
if os.path.exists(modelFileName):
|
if os.path.exists(modelDataFileName):
|
||||||
os.remove(modelFileName);
|
os.remove(modelDataFileName);
|
||||||
|
|
||||||
for numSources in sampleRange:
|
for numSources in sampleRange:
|
||||||
testname = "1 Source Point" if numSources == 1 else ("%d Source Points" % numSources);
|
testname = "1 Source Point" if numSources == 1 else ("%d Source Points" % numSources);
|
||||||
config = benchmark.TestConfig(testname, testModels, 20, numSources, 100, rand.randint(0, 65536));
|
config = benchmark.TestConfig(testname, testModels, 20, numSources, 100, rand.randint(0, 65536), kernel);
|
||||||
infoSet = {};
|
infoSet = {};
|
||||||
infoFile = tempfile.TemporaryFile();
|
infoFile = tempfile.TemporaryFile();
|
||||||
benchmark.run_benchmarks(config, infoFile);
|
benchmark.run_benchmarks(config, infoFile);
|
||||||
|
|
@ -90,26 +132,24 @@ for numSources in sampleRange:
|
||||||
infoFile.close();
|
infoFile.close();
|
||||||
for k in infoSet.keys():
|
for k in infoSet.keys():
|
||||||
print_to_datafiles(config, make_model_data_file_name(dataFileBase, k), infoSet[k]);
|
print_to_datafiles(config, make_model_data_file_name(dataFileBase, k), infoSet[k]);
|
||||||
|
if tableFileBase != None:
|
||||||
tableFile = open(make_table_file_name(tableFileBase, numSources), "w");
|
tableFile = open(make_table_file_name(tableFileBase, numSources), "w");
|
||||||
print_table(infoSet, config, tableFile);
|
print_table(infoSet, config, tableFile);
|
||||||
tableFile.close();
|
tableFile.close();
|
||||||
|
|
||||||
|
if plotFileBase != None:
|
||||||
for runParams in [('query', 4, "Average Query Time"), ('construction', 3, "Average Construction Time"), ('memory', 5, "Peak Memory Usage")]:
|
for runParams in [('query', 4, "Average Query Time"), ('construction', 3, "Average Construction Time"), ('memory', 5, "Peak Memory Usage")]:
|
||||||
plotCommands = [];
|
plotCommands = [];
|
||||||
|
|
||||||
for k in testModels:
|
for k in testModels:
|
||||||
plotCommands.append('"%s" using 1:%d with lines title "%s"' % (make_model_data_file_name(dataFileBase, k), runParams[1], os.path.basename(k)));
|
plotCommands.append('"%s" using 1:%d with lines title "%s"' % (make_model_data_file_name(dataFileBase, k), runParams[1], os.path.basename(k)));
|
||||||
|
|
||||||
plotCommand = "plot " + ', '.join(plotCommands);
|
plotCommand = "plot " + ', '.join(plotCommands);
|
||||||
|
|
||||||
plotCommandFile = tempfile.TemporaryFile();
|
plotCommandFile = tempfile.TemporaryFile();
|
||||||
plotCommandFile.write('set terminal png size 1280,960;\n');
|
plotCommandFile.write('set terminal png size 1280,960;\n');
|
||||||
plotCommandFile.write('set output "%s";\n' % make_figure_file_name(figureFileBase, runParams[0]));
|
plotCommandFile.write('set output "%s";\n' % make_figure_file_name(plotFileBase, runParams[0]));
|
||||||
plotCommandFile.write('set xlabel "Number of Source Points";\n');
|
plotCommandFile.write('set xlabel "Number of Source Points";\n');
|
||||||
plotCommandFile.write('set ylabel "%s";\n' % runParams[2]);
|
plotCommandFile.write('set ylabel "%s";\n' % runParams[2]);
|
||||||
plotCommandFile.write(plotCommand + ";\n");
|
plotCommandFile.write(plotCommand + ";\n");
|
||||||
plotCommandFile.write('unset output;\n');
|
plotCommandFile.write('unset output;\n');
|
||||||
plotCommandFile.write('quit\n');
|
plotCommandFile.write('quit\n');
|
||||||
plotCommandFile.seek(0);
|
plotCommandFile.seek(0);
|
||||||
|
|
||||||
subprocess.call(['gnuplot'], stdin=plotCommandFile);
|
subprocess.call(['gnuplot'], stdin=plotCommandFile);
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,5 @@ if [ ! -a CMakeLists.txt ]
|
||||||
cgal_create_CMakeLists -b program_options:timer -c Core
|
cgal_create_CMakeLists -b program_options:timer -c Core
|
||||||
fi
|
fi
|
||||||
|
|
||||||
python compileBenchmarks.py testModels.txt _modeldata benchmark_table benchmark_plot 6062699
|
python compileBenchmarks.py -f testModels.txt -d _modeldata -t benchmark_table -o benchmark_plot -s 6062699 -r 1 5,55,5
|
||||||
|
#python compileBenchmarks.py -k epeck -f simpleModels.txt -d _modeldata -t epeck_table -s 9894710 -r 1
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
data/cube.off
|
||||||
|
data/cross.off
|
||||||
|
data/star.off
|
||||||
Loading…
Reference in New Issue