17 #include "../logging.h"
18 #include "../tools/Tool.h"
26 namespace fs = std::filesystem;
36 std::map<const Tool*, std::size_t>
mTools;
37 std::map<fs::path, std::size_t>
mFiles;
41 std::optional<std::reference_wrapper<const BenchmarkResult>>
get(
const Tool* tool,
const fs::path& file)
const {
42 auto toolIt =
mTools.find(tool);
43 if (toolIt ==
mTools.end())
return std::nullopt;
44 auto fileIt =
mFiles.find(file);
45 if (fileIt ==
mFiles.end())
return std::nullopt;
46 auto dataIt =
mData.find(std::make_pair(toolIt->second, fileIt->second));
47 if (dataIt ==
mData.end())
return std::nullopt;
48 return std::ref(dataIt->second);
55 std::lock_guard<std::mutex> lock(
mMutex);
56 auto toolIt =
mTools.find(tool);
57 if (toolIt ==
mTools.end()) {
60 auto fileIt =
mFiles.find(file);
61 if (fileIt ==
mFiles.end()) {
65 mData.emplace(std::make_pair(toolIt->second, fileIt->second), std::move(results));
70 std::map<std::size_t, std::size_t> toolIDs;
71 std::map<std::size_t, std::size_t> fileIDs;
73 for (
const auto& it:
mTools) {
74 toolIDs[it.second] = db.
getToolID(it.first);
75 std::cout << toolIDs << std::endl;
77 for (
const auto& it:
mFiles) {
78 fileIDs[it.second] = db.
getFileID(it.first);
82 for (
const auto& it:
mData) {
83 std::size_t tool = toolIDs[it.first.first];
84 std::size_t file = fileIDs[it.first.second];
86 std::size_t
id = db.
addBenchmarkResult(benchmarkID, tool, file, it.second.exitCode, std::size_t(std::chrono::milliseconds(it.second.time).count()));
87 for (
const auto& attr: it.second.additional) {
96 xml.
write(jobs, *
this);
101 csv.
write(jobs, *
this);
Writes results to a csv file.
void write(const Jobs &jobs, const Results &results)
Write results to file.
Dummy database that effectively disables storing to database. Set BENCHMAX_DATABASE to actually use a...
Index getToolID(const Tool *)
Dummy.
void addBenchmarkAttribute(Index, const std::string &, const std::string &)
Dummy.
Index createBenchmark()
Dummy.
Index addBenchmarkResult(Index, Index, Index, int, std::size_t)
Dummy.
Index getFileID(const fs::path &)
Dummy.
Represents a set of jobs, constructed as the cartesian product of a set of tools and a set of benchma...
Stores results for for whole benchmax run.
std::map< fs::path, std::size_t > mFiles
std::map< std::pair< std::size_t, std::size_t >, BenchmarkResult > mData
const auto & data() const
void store(Database &db)
Store all results to some database.
std::optional< std::reference_wrapper< const BenchmarkResult > > get(const Tool *tool, const fs::path &file) const
std::map< const Tool *, std::size_t > mTools
void store(CSVWriter &csv, const Jobs &jobs) const
Store all results to a csl file.
void store(XMLWriter &xml, const Jobs &jobs) const
Store all results to a xml file.
void addResult(const Tool *tool, const fs::path &file, BenchmarkResult &&results)
Add a new result.
Writes results to a xml file.
void write(const Jobs &jobs, const Results &results)
Write results to file.
Results for a single benchmark run.