diff --git a/include/chopper/configuration.hpp b/include/chopper/configuration.hpp index 82473d3e..3568053b 100644 --- a/include/chopper/configuration.hpp +++ b/include/chopper/configuration.hpp @@ -29,6 +29,9 @@ struct configuration //!\brief Internal parameter that triggers some verbose debug output. bool debug{false}; + + //!\brief If specified, layout timings are written to the specified file. + std::filesystem::path output_timings{}; //!\} /*!\name Configuration of size estimates (chopper::count) diff --git a/lib/hibf b/lib/hibf index cc744d96..f7c341c9 160000 --- a/lib/hibf +++ b/lib/hibf @@ -1 +1 @@ -Subproject commit cc744d96a764170610851509fca98f2c3d71830a +Subproject commit f7c341c9eaaea8dd920bf4039f0d32c258c6e811 diff --git a/src/chopper.cpp b/src/chopper.cpp index d8f002fd..77a32709 100644 --- a/src/chopper.cpp +++ b/src/chopper.cpp @@ -39,6 +39,8 @@ int main(int argc, char const * argv[]) else if (config.k > config.window_size) throw sharg::parser_error{"The k-mer size cannot be bigger than the window size."}; + assert(parser.is_option_set("timing-output") && !config.output_timings.empty()); + config.disable_sketch_output = !parser.is_option_set("output-sketches-to"); } catch (sharg::parser_error const & ext) // the user did something wrong diff --git a/src/layout/execute.cpp b/src/layout/execute.cpp index 48110377..7d90f796 100644 --- a/src/layout/execute.cpp +++ b/src/layout/execute.cpp @@ -61,6 +61,11 @@ int execute(chopper::configuration & config, std::vector const & fi seqan::hibf::layout::layout hibf_layout; std::vector sketches; + seqan::hibf::concurrent_timer compute_sketches_timer{}; + seqan::hibf::concurrent_timer union_estimation_timer{}; + seqan::hibf::concurrent_timer rearrangement_timer{}; + seqan::hibf::concurrent_timer dp_algorithm_timer{}; + if (config.determine_best_tmax) { std::tie(hibf_layout, sketches) = determine_best_number_of_technical_bins(config); @@ -69,8 +74,16 @@ int execute(chopper::configuration & config, std::vector const & fi { std::vector kmer_counts; + compute_sketches_timer.start(); seqan::hibf::sketch::compute_sketches(config.hibf_config, kmer_counts, sketches); - hibf_layout = seqan::hibf::layout::compute_layout(config.hibf_config, kmer_counts, sketches); + compute_sketches_timer.stop(); + dp_algorithm_timer.start(); + hibf_layout = seqan::hibf::layout::compute_layout(config.hibf_config, + kmer_counts, + sketches, + union_estimation_timer, + rearrangement_timer); + dp_algorithm_timer.stop(); if (config.output_verbose_statistics) { @@ -98,6 +111,20 @@ int execute(chopper::configuration & config, std::vector const & fi config.write_to(fout); hibf_layout.write_to(fout); + if (!config.output_timings.empty()) + { + std::ofstream output_stream{config.output_timings}; + output_stream << std::fixed << std::setprecision(2); + output_stream << "sketching_in_seconds\t" + << "layouting_in_seconds\t" + << "union_estimation_in_seconds\t" + << "rearrangement_in_seconds\n"; + output_stream << compute_sketches_timer.in_seconds() << '\t'; + output_stream << dp_algorithm_timer.in_seconds() << '\t'; + output_stream << union_estimation_timer.in_seconds() << '\t'; + output_stream << rearrangement_timer.in_seconds() << '\t'; + } + return 0; } diff --git a/src/set_up_parser.cpp b/src/set_up_parser.cpp index 5b64d8d1..b9555c7c 100644 --- a/src/set_up_parser.cpp +++ b/src/set_up_parser.cpp @@ -78,6 +78,11 @@ void set_up_parser(sharg::parser & parser, configuration & config) "accuracy.", .default_message = "k-mer size", }); + parser.add_option(config.output_timings, + sharg::config{.short_id = '\0', + .long_id = "timing-output", + .description = "Write time and memory usage to specified file (TSV format). ", + .default_message = ""}); parser.add_option( config.hibf_config.tmax,