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& filename: jobs.
files()) {
46 const auto& run = results.
get(tool, filename);
49 for (
const auto& stat: run->get().additional) {
50 res.emplace_back(stat.first);
57 std::unique(res.begin(), res.end()),
68 template<
typename Results>
70 std::map<Tool*,std::vector<std::string>> tool_stats;
72 std::stringstream second_row;
75 for (
const auto& tool: jobs.
tools()) {
77 second_row <<
",answer,exitcode,runtime";
79 for (
const auto& s: tool_stats.at(tool.get())) {
84 mFile << std::endl << second_row.rdbuf() << std::endl;
86 for (
const auto& filename: jobs.
files()) {
88 for (
const auto& tool: jobs.
tools()) {
89 const auto&
result = results.
get(tool.get(), filename);
92 for (std::size_t i = 0; i < tool_stats.at(tool.get()).size(); i++) {
96 const auto& res =
result->get();
98 mFile <<
"," << res.answer <<
"," << res.exitCode <<
"," << std::chrono::milliseconds(res.time).count();
99 for (
const auto& stat : tool_stats.at(tool.get())) {
101 if (res.additional.find(stat) != res.additional.end()) {
102 mFile <<
"\"" << res.additional.at(stat) <<
"\"";
Writes results to a csv file.
std::string sanitizeFile(const fs::path &file) const
void replace(std::string &s, const std::string &pattern, const std::string &replacement) const
CSVWriter(const std::string &filename)
Open file for writing.
std::string sanitize(const std::string &s, bool eliminateSlashes=false) const
std::vector< std::string > collectStatistics(const Jobs &jobs, const Results &results, Tool *tool) const
void write(const Jobs &jobs, const Results &results)
Write results to file.
std::string sanitizeTool(const std::unique_ptr< Tool > &tool) const
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.
std::optional< std::reference_wrapper< const BenchmarkResult > > get(const Tool *tool, 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.