Commit f41a5035 authored by RomainFeron's avatar RomainFeron
Browse files

Added start and end of function logs with runtime

parent 1fedd85a
......@@ -3,6 +3,9 @@
void depth(Parameters& parameters) {
std::chrono::steady_clock::time_point t_begin = std::chrono::steady_clock::now();
log("RADSex depth started");
Popmap popmap = load_popmap(parameters);
Header header;
......@@ -61,6 +64,8 @@ void depth(Parameters& parameters) {
}
log("RADSex depth ended (total runtime: " + get_runtime(t_begin) + ")");
}
......
......@@ -8,6 +8,9 @@ void distrib(Parameters& parameters) {
* <int> | <int> | <int> | <float> | <bool>
*/
std::chrono::steady_clock::time_point t_begin = std::chrono::steady_clock::now();
log("RADSex distrib started");
Popmap popmap = load_popmap(parameters);
Header header;
......@@ -50,6 +53,8 @@ void distrib(Parameters& parameters) {
output_distrib_matrix(parameters.output_file_path, results, popmap.counts[parameters.group1], popmap.counts[parameters.group2]);
}
log("RADSex distrib ended (total runtime: " + get_runtime(t_begin) + ")");
}
......
......@@ -8,6 +8,9 @@ void freq(Parameters& parameters) {
* Number of individuals | Number of markers found in this number of individuals
*/
std::chrono::steady_clock::time_point t_begin = std::chrono::steady_clock::now();
log("RADSex freq started");
Header header = get_header(parameters.markers_table_path);
Popmap popmap; // Create dummy popmap
uint n_individuals = header.size() - 1; // Number of columns - 2 (id and seq columns) +1 (because range is 0 - n_individuals)
......@@ -32,6 +35,8 @@ void freq(Parameters& parameters) {
for (uint i=1; i < n_individuals; ++i) output_file << i << "\t" << frequencies[i] << "\n"; // Iterate over the map
output_file.close();
log("RADSex freq ended (total runtime: " + get_runtime(t_begin) + ")");
}
......
......@@ -19,6 +19,9 @@ void map(Parameters& parameters) {
* - They are mapped uniquely, that is, there is no other mapping position with the same mapping score for this sequence. *
*/
std::chrono::steady_clock::time_point t_begin = std::chrono::steady_clock::now();
log("RADSex map started");
// Popmap
Popmap popmap = load_popmap(parameters);
Header header;
......@@ -55,6 +58,8 @@ void map(Parameters& parameters) {
output_file.close();
log("RADSex map ended (total runtime: " + get_runtime(t_begin) + ")");
}
......
......@@ -77,6 +77,9 @@ void process(Parameters& parameters) {
* - once all files are processed, output the results
*/
std::chrono::steady_clock::time_point t_begin = std::chrono::steady_clock::now();
log("RADSex process started");
if (parameters.input_dir_path.back() != '/') parameters.input_dir_path += "/"; // Append "/" to the end of the path if it's missing
std::vector<InputFile> input_files = get_input_files(parameters.input_dir_path);
......@@ -134,6 +137,8 @@ void process(Parameters& parameters) {
log_progress(n_processed_markers, marker_processed_tick);
}
log("RADSex process ended (total runtime: " + get_runtime(t_begin) + ")");
}
......
......@@ -8,6 +8,9 @@ void signif(Parameters& parameters) {
* <int> | <int> | <int> | <float> | <bool>
*/
std::chrono::steady_clock::time_point t_begin = std::chrono::steady_clock::now();
log("RADSex signif started");
Popmap popmap = load_popmap(parameters);
Header header;
......@@ -40,6 +43,8 @@ void signif(Parameters& parameters) {
}
output_file.close();
log("RADSex signif ended (total runtime: " + get_runtime(t_begin) + ")");
}
......
......@@ -2,6 +2,9 @@
void subset(Parameters& parameters) {
std::chrono::steady_clock::time_point t_begin = std::chrono::steady_clock::now();
log("RADSex subset started");
Popmap popmap = load_popmap(parameters);
Header header;
......@@ -18,6 +21,8 @@ void subset(Parameters& parameters) {
processing_thread.join();
output_file.close();
log("RADSex subset ended (total runtime: " + get_runtime(t_begin) + ")");
}
......
......@@ -134,7 +134,7 @@ inline std::ofstream open_output(const std::string& output_file_path) {
inline void log_progress(uint64_t& n_processed_markers, uint32_t marker_processed_tick) {
inline void log_progress(uint64_t& n_processed_markers, const uint32_t marker_processed_tick) {
if (++n_processed_markers % (10 * marker_processed_tick) == 0) {
......@@ -142,3 +142,15 @@ inline void log_progress(uint64_t& n_processed_markers, uint32_t marker_processe
}
}
inline std::string get_runtime(const std::chrono::steady_clock::time_point t_begin) {
std::chrono::steady_clock::time_point t_end = std::chrono::steady_clock::now();
long seconds = std::chrono::duration_cast<std::chrono::seconds>(t_end - t_begin).count();
long minutes = seconds / 60;
long hours = minutes / 60;
std::string runtime = std::to_string(hours) + "h " + std::to_string(minutes%60) + "m " + std::to_string(seconds%60) + "s";
return runtime;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment