Skip to content

Commit 8faf63e

Browse files
authored
Merge pull request #341 from guilhermeAlmeida1/wipLogResultsMt
2 parents 25abc74 + a298d43 commit 8faf63e

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

examples/options/include/traccc/options/throughput_options.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ struct throughput_options {
4646
/// them in the performance measurements
4747
std::size_t cold_run_events = 10;
4848

49+
/// Output log file
50+
std::string log_file;
51+
4952
/// Constructor on top of a common @c program_options object
5053
///
5154
/// @param desc The program options to add to

examples/options/src/options/throughput_options.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ throughput_options::throughput_options(po::options_description& desc) {
4343
desc.add_options()("cold_run_events",
4444
po::value<std::size_t>()->default_value(10),
4545
"Number of events to run 'cold'");
46+
desc.add_options()(
47+
"log_file",
48+
po::value<std::string>()->default_value(
49+
"\0", "File where result logs will be printed (in append mode)."));
4650
}
4751

4852
void throughput_options::read(const po::variables_map& vm) {
@@ -69,6 +73,7 @@ void throughput_options::read(const po::variables_map& vm) {
6973
loaded_events = vm["loaded_events"].as<std::size_t>();
7074
processed_events = vm["processed_events"].as<std::size_t>();
7175
cold_run_events = vm["cold_run_events"].as<std::size_t>();
76+
log_file = vm["log_file"].as<std::string>();
7277
}
7378

7479
std::ostream& operator<<(std::ostream& out, const throughput_options& opt) {
@@ -83,7 +88,8 @@ std::ostream& operator<<(std::ostream& out, const throughput_options& opt) {
8388
<< "\n"
8489
<< "Loaded event(s) : " << opt.loaded_events << "\n"
8590
<< "Cold run event(s) : " << opt.cold_run_events << "\n"
86-
<< "Processed event(s) : " << opt.processed_events;
91+
<< "Processed event(s) : " << opt.processed_events << "\n"
92+
<< "Log_file : " << opt.log_file;
8793
return out;
8894
}
8995

examples/run/common/throughput_mt.ipp

+14
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <atomic>
3333
#include <cstdlib>
3434
#include <ctime>
35+
#include <fstream>
3536
#include <iostream>
3637
#include <memory>
3738
#include <vector>
@@ -190,6 +191,19 @@ int throughput_mt(std::string_view description, int argc, char* argv[],
190191
"Event processing"}
191192
<< std::endl;
192193

194+
// Print results to log file
195+
if (throughput_cfg.log_file != "\0") {
196+
std::ofstream logFile;
197+
logFile.open(throughput_cfg.log_file, std::fstream::app);
198+
logFile << "\"" << throughput_cfg.input_directory << "\""
199+
<< "," << mt_cfg.threads << "," << throughput_cfg.loaded_events
200+
<< "," << throughput_cfg.cold_run_events << ","
201+
<< throughput_cfg.processed_events << ","
202+
<< times.get_time("Warm-up processing").count() << ","
203+
<< times.get_time("Event processing").count() << std::endl;
204+
logFile.close();
205+
}
206+
193207
// Return gracefully.
194208
return 0;
195209
}

examples/run/common/throughput_mt_alt.ipp

+14
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <atomic>
3838
#include <cstdlib>
3939
#include <ctime>
40+
#include <fstream>
4041
#include <iostream>
4142
#include <memory>
4243
#include <vector>
@@ -210,6 +211,19 @@ int throughput_mt_alt(std::string_view description, int argc, char* argv[],
210211
"Event processing"}
211212
<< std::endl;
212213

214+
// Print results to log file
215+
if (throughput_cfg.log_file != "\0") {
216+
std::ofstream logFile;
217+
logFile.open(throughput_cfg.log_file, std::fstream::app);
218+
logFile << "\"" << throughput_cfg.input_directory << "\""
219+
<< "," << mt_cfg.threads << "," << throughput_cfg.loaded_events
220+
<< "," << throughput_cfg.cold_run_events << ","
221+
<< throughput_cfg.processed_events << ","
222+
<< times.get_time("Warm-up processing").count() << ","
223+
<< times.get_time("Event processing").count() << std::endl;
224+
logFile.close();
225+
}
226+
213227
// Return gracefully.
214228
return 0;
215229
}

0 commit comments

Comments
 (0)