12 #include "../utils/execute.h"
14 #include "../utils/parsing.h"
24 virtual void execute(
const Tool* tool,
const fs::path& file) {
25 std::stringstream call;
26 call <<
"ulimit -S -t " << std::chrono::seconds(
settings_benchmarks().limit_time).count() <<
" && ";
28 call <<
"date +\"Start: %s%3N\" && ";
29 call <<
"/usr/bin/time -v ";
30 call << tool->
getCommandline(file.native()) <<
" 2> stderr.log && ";
31 call <<
"date +\"End: %s%3N\"";
34 auto start = std::chrono::high_resolution_clock::now();
37 results.
exitCode = WEXITSTATUS(exitCode);
39 auto end = std::chrono::high_resolution_clock::now();
40 results.
time = std::chrono::duration_cast<decltype(results.
time)>(end - start);
42 std::ifstream ifs(
"stderr.log");
43 results.
stderr.assign((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
47 addResult(tool, file, std::move(results));
Base class for all backends.
void madeProgress(std::size_t files=1)
Can be called to give information about the current progress, if available.
void addResult(const Tool *tool, const fs::path &file, BenchmarkResult &&result)
Add a result.
This backend simply runs files sequentially on the local machine.
virtual void execute(const Tool *tool, const fs::path &file)
Execute the tool on the file manually.
int call_program(const std::string &commandline, std::string &stdout, bool print_to_stdout=false)
Runs an external program from some command line and records the output to stdout.
const auto & settings_benchmarks()
Return the benchmark settings.
std::size_t parse_peak_memory(const std::string &output)
Results for a single benchmark run.
int exitCode
Shell exit code.
std::string stdout
Standard output (mostly for parsing the answer and additional information).
std::chrono::milliseconds time
Runtime in milliseconds.
std::string stderr
Error output (mostly for parsing the answer and additional information).
std::size_t peak_memory_kbytes
Peak memory usage.