22 void replace(std::string& s,
const std::string& pattern,
const std::string& replacement)
const {
24 while ((pos = s.find(pattern, pos)) != std::string::npos) {
25 s.replace(pos, pattern.length(), replacement);
26 pos += replacement.length();
29 std::string
sanitize(
const std::string& s,
bool eliminateSlashes =
false)
const {
33 if (eliminateSlashes)
replace(res,
"/",
".");
36 std::string
sanitizeTool(
const std::unique_ptr<Tool>& tool)
const {
42 template<
typename Results>
44 std::vector<std::string> res;
45 for (
const auto& run: results.
data()) {
47 for (
const auto& stat: run.second.additional) {
48 res.emplace_back(stat.first);
54 std::unique(res.begin(), res.end()),
65 template<
typename Results>
67 mFile <<
"<?xml version=\"1.0\"?>" << std::endl;
68 mFile <<
"<results>" << std::endl;
69 mFile <<
"\t<information>" << std::endl;
70 mFile <<
"\t\t<info name=\"timeout\" type=\"seconds\" value=\"" << std::chrono::seconds(
settings_benchmarks().limit_time).count() <<
"\" />" << std::endl;
71 mFile <<
"\t</information>" << std::endl;
72 mFile <<
"\t<solvers prefix=\"" <<
settings_tools().tools_common_prefix.native() <<
"\">" << std::endl;
73 for (
const auto& tool: jobs.
tools()) {
74 mFile <<
"\t\t<solver solver_id=\"" <<
sanitizeTool(tool) <<
"\" />" << std::endl;
76 mFile <<
"\t</solvers>" << std::endl;
77 mFile <<
"\t<statistics>" << std::endl;
79 mFile <<
"\t\t<stat name=\"" <<
sanitize(s) <<
"\" />" << std::endl;
81 mFile <<
"\t</statistics>" << std::endl;
83 mFile <<
"\t<benchmarks prefix=\"" <<
settings_benchmarks().input_directories_common_prefix.native() <<
"\">" << std::endl;
84 for (
const auto& filename: jobs.
files()) {
86 for (
const auto& tool: jobs.
tools()) {
87 const auto&
result = results.
get(tool.get(), filename);
89 const auto& res =
result->get();
92 if (!res.additional.empty()) {
93 mFile <<
"\t\t\t\t<statistics>" << std::endl;
94 for (
const auto& stat: res.additional) {
95 mFile <<
"\t\t\t\t\t<stat name=\"" <<
sanitize(stat.first) <<
"\">" << stat.second <<
"</stat>" << std::endl;
97 mFile <<
"\t\t\t\t</statistics>" << std::endl;
99 mFile <<
"\t\t\t\t<results>" << std::endl;
100 mFile <<
"\t\t\t\t\t<result name=\"answer\" type=\"string\">" << res.answer <<
"</result>" << std::endl;
101 mFile <<
"\t\t\t\t\t<result name=\"exitcode\" type=\"int\">" << res.exitCode <<
"</result>" << std::endl;
102 mFile <<
"\t\t\t\t\t<result name=\"runtime\" type=\"milliseconds\">" << std::chrono::milliseconds(res.time).count() <<
"</result>" << std::endl;
103 mFile <<
"\t\t\t\t</results>" << std::endl;
104 mFile <<
"\t\t\t</run>" << std::endl;
107 mFile <<
"\t\t</file>" << std::endl;
109 mFile <<
"\t</benchmarks>" << std::endl;
110 mFile <<
"</results>" << std::endl;
Represents a set of jobs, constructed as the cartesian product of a set of tools and a set of benchma...
const auto & files() const
Returns the set of files.
const auto & tools() const
Returns the set of tools.
Stores results for for whole benchmax run.
const auto & data() const
std::optional< std::reference_wrapper< const BenchmarkResult > > get(const Tool *tool, const fs::path &file) const
Writes results to a xml file.
XMLWriter(const std::string &filename)
Open file for writing.
std::string sanitize(const std::string &s, bool eliminateSlashes=false) const
void replace(std::string &s, const std::string &pattern, const std::string &replacement) const
std::string sanitizeTool(const std::unique_ptr< Tool > &tool) const
void write(const Jobs &jobs, const Results &results)
Write results to file.
std::vector< std::string > collectStatistics(const Results &results) const
std::string sanitizeFile(const fs::path &file) const
void sort(T *array, int size, LessThan lt)
const auto & settings_benchmarks()
Return the benchmark settings.
std::filesystem::path remove_prefix(const std::filesystem::path &s, const std::filesystem::path &prefix)
Remove a prefix from a path.
const auto & settings_tools()
Returns the tool settings.