From 0065c8b75771bdf97508890be892dcf6fce433d0 Mon Sep 17 00:00:00 2001 From: Roberto Rossini <71787608+robomics@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:25:04 +0100 Subject: [PATCH] Simplify interaction_fetching benchmarks --- .../cooler_cis_queries.cpp | 56 ++++------------- .../cooler_trans_queries.cpp | 57 +++++------------- .../interaction_fetching/file_cis_queries.cpp | 59 ++++-------------- .../interaction_fetching/file_gw_queries.cpp | 1 - .../file_trans_queries.cpp | 60 +++++-------------- .../interaction_fetching/hic_cis_queries.cpp | 56 ++++------------- .../hic_trans_queries.cpp | 57 +++++------------- 7 files changed, 87 insertions(+), 259 deletions(-) diff --git a/benchmark/interaction_fetching/cooler_cis_queries.cpp b/benchmark/interaction_fetching/cooler_cis_queries.cpp index 08391e67..4f13c7a0 100644 --- a/benchmark/interaction_fetching/cooler_cis_queries.cpp +++ b/benchmark/interaction_fetching/cooler_cis_queries.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include "./common.hpp" @@ -21,43 +23,22 @@ static const std::filesystem::path test_file{"test/data/integration_tests/4DNFIZ static const std::vector resolutions{1000, 5000, 10000, 25000, 50000, 100000, 250000, 500000, 1000000, 2500000}; -static const auto w = balancing::Method::KR(); - -static const std::vector params_uint{ - {"cis; small; normalization=NONE; symmetric", true, 100e3, 100e3, 25e3, 25e3}, - {"cis; medium; normalization=NONE; symmetric", true}, - {"cis; large; normalization=NONE; symmetric", true, 5e6, 5e6, 500e3, 500e3}, -}; - -static const std::vector params_fp{ - {"cis; small; normalization=weight; symmetric", true, 100e3, 100e3, 25e3, 25e3, 1, w}, - {"cis; medium; normalization=weight; symmetric", true, 1.0e6, 1.0e6, 250e3, 250e3, 1, w}, - {"cis; large; normalization=weight; symmetric", true, 5e6, 5e6, 500e3, 500e3, 1, w}, -}; +static constexpr std::string_view range_small{"chr2L:5,000,000-5,100,000"}; +static constexpr std::string_view range_medium{"chr2L:6,000,000-7,000,000"}; +static constexpr std::string_view range_large{"chr2L:10,000,000-15,000,000"}; TEST_CASE("cooler::File::fetch (cis; uint32)") { const auto chroms = cooler::File(fmt::format(FMT_STRING("{}::/resolutions/{}"), test_file.string(), resolutions.back())) .chromosomes(); for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_uint) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(0); - const auto& chrom2 = cis ? chrom1 : chroms.at(3); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), label, res)) + for (const auto& range : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), range, res)) (Catch::Benchmark::Chronometer meter) { const cooler::File clr( fmt::format(FMT_STRING("{}::/resolutions/{}"), test_file.string(), res)); - meter.measure([&clr, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(clr, range1, range2, normalization); - } - return nnz; + meter.measure([&clr, &range]() { + return count_nnz(clr, range, range, balancing::Method::NONE()); }); }; } @@ -69,24 +50,13 @@ TEST_CASE("cooler::File::fetch (cis; double)") { test_file.string(), resolutions.back())) .chromosomes(); for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_fp) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(0); - const auto& chrom2 = cis ? chrom1 : chroms.at(3); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), label, res)) + for (const auto& range : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), range, res)) (Catch::Benchmark::Chronometer meter) { const cooler::File clr( fmt::format(FMT_STRING("{}::/resolutions/{}"), test_file.string(), res)); - meter.measure([&clr, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(clr, range1, range2, normalization); - } - return nnz; + meter.measure([&clr, &range]() { + return count_nnz(clr, range, range, balancing::Method::KR()); }); }; } diff --git a/benchmark/interaction_fetching/cooler_trans_queries.cpp b/benchmark/interaction_fetching/cooler_trans_queries.cpp index cb99cd9a..7f75ac19 100644 --- a/benchmark/interaction_fetching/cooler_trans_queries.cpp +++ b/benchmark/interaction_fetching/cooler_trans_queries.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include "./common.hpp" @@ -21,43 +23,27 @@ static const std::filesystem::path test_file{"test/data/integration_tests/4DNFIZ static const std::vector resolutions{1000, 5000, 10000, 25000, 50000, 100000, 250000, 500000, 1000000, 2500000}; -static const auto w = balancing::Method::KR(); +static constexpr std::pair range_small{ + "chr2L:15,000,000-15,100,000", "chrX:10,200,000-10,300,000"}; -static const std::vector params_uint{ - {"trans; small; normalization=NONE; symmetric", false, 100e3, 100e3, 25e3, 25e3}, - {"trans; medium; normalization=NONE; symmetric", false}, - {"trans; large; normalization=NONE; symmetric", false, 5e6, 5e6, 500e3, 500e3}, -}; +static constexpr std::pair range_medium{ + "chr2L:5,000,000-6,000,000", "chrX:5,000,000-6,000,000"}; -static const std::vector params_fp{ - {"trans; small; normalization=weight; symmetric", false, 100e3, 100e3, 25e3, 25e3, 1, w}, - {"trans; medium; normalization=weight; symmetric", false, 1.0e6, 1.0e6, 250e3, 250e3, 1, w}, - {"trans; large; normalization=weight; symmetric", false, 5e6, 5e6, 500e3, 500e3, 1, w}, -}; +static constexpr std::pair range_large{ + "chr2L:15,000,000-20,000,000", "chrX:15,000,000-20,000,000"}; TEST_CASE("cooler::File::fetch (trans; uint32)") { const auto chroms = cooler::File(fmt::format(FMT_STRING("{}::/resolutions/{}"), test_file.string(), resolutions.back())) .chromosomes(); for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_uint) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(0); - const auto& chrom2 = cis ? chrom1 : chroms.at(3); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), label, res)) + for (const auto& query : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), query.first, query.second, res)) (Catch::Benchmark::Chronometer meter) { const cooler::File clr( fmt::format(FMT_STRING("{}::/resolutions/{}"), test_file.string(), res)); - meter.measure([&clr, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(clr, range1, range2, normalization); - } - return nnz; + meter.measure([&clr, range1 = query.first, range2 = query.second]() { + return count_nnz(clr, range1, range2, balancing::Method::NONE()); }); }; } @@ -69,24 +55,13 @@ TEST_CASE("cooler::File::fetch (trans; double)") { test_file.string(), resolutions.back())) .chromosomes(); for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_fp) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(0); - const auto& chrom2 = cis ? chrom1 : chroms.at(3); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), label, res)) + for (const auto& query : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), query.first, query.second, res)) (Catch::Benchmark::Chronometer meter) { const cooler::File clr( fmt::format(FMT_STRING("{}::/resolutions/{}"), test_file.string(), res)); - meter.measure([&clr, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(clr, range1, range2, normalization); - } - return nnz; + meter.measure([&clr, range1 = query.first, range2 = query.second]() { + return count_nnz(clr, range1, range2, balancing::Method::KR()); }); }; } diff --git a/benchmark/interaction_fetching/file_cis_queries.cpp b/benchmark/interaction_fetching/file_cis_queries.cpp index fbe2c8ea..595bbcd6 100644 --- a/benchmark/interaction_fetching/file_cis_queries.cpp +++ b/benchmark/interaction_fetching/file_cis_queries.cpp @@ -8,12 +8,13 @@ #include #include #include +#include +#include #include #include "./common.hpp" #include "hictk/balancing/methods.hpp" #include "hictk/cooler/cooler.hpp" -#include "hictk/cooler/validation.hpp" #include "hictk/file.hpp" using namespace hictk; @@ -25,19 +26,9 @@ static const std::filesystem::path test_file3{"test/data/hic/4DNFIZ1ZVXC8.hic9"} static const std::vector resolutions{1000, 5000, 10000, 25000, 50000, 100000, 250000, 500000, 1000000, 2500000}; -static const auto w = balancing::Method::KR(); - -static const std::vector params_uint{ - {"cis; small; normalization=NONE; symmetric", true, 100e3, 100e3, 25e3, 25e3}, - {"cis; medium; normalization=NONE; symmetric", true}, - {"cis; large; normalization=NONE; symmetric", true, 5e6, 5e6, 500e3, 500e3}, -}; - -static const std::vector params_fp{ - {"cis; small; normalization=weight; symmetric", true, 100e3, 100e3, 25e3, 25e3, 1, w}, - {"cis; medium; normalization=weight; symmetric", true, 1.0e6, 1.0e6, 250e3, 250e3, 1, w}, - {"cis; large; normalization=weight; symmetric", true, 5e6, 5e6, 500e3, 500e3, 1, w}, -}; +static constexpr std::string_view range_small{"chr2L:5,000,000-5,100,000"}; +static constexpr std::string_view range_medium{"chr2L:6,000,000-7,000,000"}; +static constexpr std::string_view range_large{"chr2L:10,000,000-15,000,000"}; TEST_CASE("File::fetch (cis; uint32)") { const auto chroms = cooler::File(fmt::format(FMT_STRING("{}::/resolutions/{}"), @@ -45,25 +36,13 @@ TEST_CASE("File::fetch (cis; uint32)") { .chromosomes(); for (const auto& path : {test_file1, test_file2, test_file3}) { - const std::uint32_t chrom_id_offset = cooler::utils::is_multires_file(path.string()) ? 0 : 1; for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_uint) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(0 + chrom_id_offset); - const auto& chrom2 = cis ? chrom1 : chroms.at(3 + chrom_id_offset); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), path.extension(), label, res)) + for (const auto& range : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), path.extension(), range, res)) (Catch::Benchmark::Chronometer meter) { const File f(path.string(), res); - meter.measure([&f, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(f, range1, range2, normalization); - } - return nnz; + meter.measure([&f, &range]() { + return count_nnz(f, range, range, balancing::Method::NONE()); }); }; } @@ -77,25 +56,13 @@ TEST_CASE("File::fetch (cis; double)") { .chromosomes(); for (const auto& path : {test_file1, test_file2, test_file3}) { - const std::uint32_t chrom_id_offset = cooler::utils::is_multires_file(path.string()) ? 0 : 1; for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_fp) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(0 + chrom_id_offset); - const auto& chrom2 = cis ? chrom1 : chroms.at(3 + chrom_id_offset); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), path.extension(), label, res)) + for (const auto& range : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), path.extension(), range, res)) (Catch::Benchmark::Chronometer meter) { const File f(path.string(), res); - meter.measure([&f, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(f, range1, range2, normalization); - } - return nnz; + meter.measure([&f, &range]() { + return count_nnz(f, range, range, balancing::Method::KR()); }); }; } diff --git a/benchmark/interaction_fetching/file_gw_queries.cpp b/benchmark/interaction_fetching/file_gw_queries.cpp index 4e148cd3..41dd932f 100644 --- a/benchmark/interaction_fetching/file_gw_queries.cpp +++ b/benchmark/interaction_fetching/file_gw_queries.cpp @@ -13,7 +13,6 @@ #include "./common.hpp" #include "hictk/balancing/methods.hpp" #include "hictk/cooler/cooler.hpp" -#include "hictk/cooler/validation.hpp" #include "hictk/file.hpp" using namespace hictk; diff --git a/benchmark/interaction_fetching/file_trans_queries.cpp b/benchmark/interaction_fetching/file_trans_queries.cpp index 2919a2d6..def45a94 100644 --- a/benchmark/interaction_fetching/file_trans_queries.cpp +++ b/benchmark/interaction_fetching/file_trans_queries.cpp @@ -8,12 +8,13 @@ #include #include #include +#include +#include #include #include "./common.hpp" #include "hictk/balancing/methods.hpp" #include "hictk/cooler/cooler.hpp" -#include "hictk/cooler/validation.hpp" #include "hictk/file.hpp" using namespace hictk; @@ -25,19 +26,14 @@ static const std::filesystem::path test_file3{"test/data/hic/4DNFIZ1ZVXC8.hic9"} static const std::vector resolutions{1000, 5000, 10000, 25000, 50000, 100000, 250000, 500000, 1000000, 2500000}; -static const auto w = balancing::Method::KR(); +static constexpr std::pair range_small{ + "chr2L:15,000,000-15,100,000", "chrX:10,200,000-10,300,000"}; -static const std::vector params_uint{ - {"trans; small; normalization=NONE; symmetric", false, 100e3, 100e3, 25e3, 25e3}, - {"trans; medium; normalization=NONE; symmetric", false}, - {"trans; large; normalization=NONE; symmetric", false, 5e6, 5e6, 500e3, 500e3}, -}; +static constexpr std::pair range_medium{ + "chr2L:5,000,000-6,000,000", "chrX:5,000,000-6,000,000"}; -static const std::vector params_fp{ - {"trans; small; normalization=weight; symmetric", false, 100e3, 100e3, 25e3, 25e3, 1, w}, - {"trans; medium; normalization=weight; symmetric", false, 1.0e6, 1.0e6, 250e3, 250e3, 1, w}, - {"trans; large; normalization=weight; symmetric", false, 5e6, 5e6, 500e3, 500e3, 1, w}, -}; +static constexpr std::pair range_large{ + "chr2L:15,000,000-20,000,000", "chrX:15,000,000-20,000,000"}; TEST_CASE("File::fetch (trans; uint32)") { const auto chroms = cooler::File(fmt::format(FMT_STRING("{}::/resolutions/{}"), @@ -45,25 +41,13 @@ TEST_CASE("File::fetch (trans; uint32)") { .chromosomes(); for (const auto& path : {test_file1, test_file2, test_file3}) { - const std::uint32_t chrom_id_offset = cooler::utils::is_multires_file(path.string()) ? 0 : 1; for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_uint) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(0 + chrom_id_offset); - const auto& chrom2 = cis ? chrom1 : chroms.at(3 + chrom_id_offset); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), path.extension(), label, res)) + for (const auto& query : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), query.first, query.second, res)) (Catch::Benchmark::Chronometer meter) { const File f(path.string(), res); - meter.measure([&f, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(f, range1, range2, normalization); - } - return nnz; + meter.measure([&f, range1 = query.first, range2 = query.second]() { + return count_nnz(f, range1, range2, balancing::Method::NONE()); }); }; } @@ -77,25 +61,13 @@ TEST_CASE("File::fetch (trans; double)") { .chromosomes(); for (const auto& path : {test_file1, test_file2, test_file3}) { - const std::uint32_t chrom_id_offset = cooler::utils::is_multires_file(path.string()) ? 0 : 1; for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_fp) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(0 + chrom_id_offset); - const auto& chrom2 = cis ? chrom1 : chroms.at(3 + chrom_id_offset); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), path.extension(), label, res)) + for (const auto& query : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), query.first, query.second, res)) (Catch::Benchmark::Chronometer meter) { const File f(path.string(), res); - meter.measure([&f, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(f, range1, range2, normalization); - } - return nnz; + meter.measure([&f, range1 = query.first, range2 = query.second]() { + return count_nnz(f, range1, range2, balancing::Method::KR()); }); }; } diff --git a/benchmark/interaction_fetching/hic_cis_queries.cpp b/benchmark/interaction_fetching/hic_cis_queries.cpp index c5c4eb4a..4eebb1d5 100644 --- a/benchmark/interaction_fetching/hic_cis_queries.cpp +++ b/benchmark/interaction_fetching/hic_cis_queries.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include "./common.hpp" @@ -22,42 +24,21 @@ static const std::filesystem::path test_file2{"test/data/hic/4DNFIZ1ZVXC8.hic9"} static const std::vector resolutions{1000, 5000, 10000, 25000, 50000, 100000, 250000, 500000, 1000000, 2500000}; -static const auto w = balancing::Method::KR(); - -static const std::vector params_uint{ - {"cis; small; normalization=NONE; symmetric", true, 100e3, 100e3, 25e3, 25e3}, - {"cis; medium; normalization=NONE; symmetric", true}, - {"cis; large; normalization=NONE; symmetric", true, 5e6, 5e6, 500e3, 500e3}, -}; - -static const std::vector params_fp{ - {"cis; small; normalization=weight; symmetric", true, 100e3, 100e3, 25e3, 25e3, 1, w}, - {"cis; medium; normalization=weight; symmetric", true, 1.0e6, 1.0e6, 250e3, 250e3, 1, w}, - {"cis; large; normalization=weight; symmetric", true, 5e6, 5e6, 500e3, 500e3, 1, w}, -}; +static constexpr std::string_view range_small{"chr2L:5,000,000-5,100,000"}; +static constexpr std::string_view range_medium{"chr2L:6,000,000-7,000,000"}; +static constexpr std::string_view range_large{"chr2L:10,000,000-15,000,000"}; TEST_CASE("hic::File::fetch (cis; uint32)") { const auto chroms = hic::File(test_file1.string(), resolutions.back()).chromosomes(); for (const auto& path : {test_file1, test_file2}) { for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_uint) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(1); - const auto& chrom2 = cis ? chrom1 : chroms.at(4); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), label, res)) + for (const auto& range : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), range, res)) (Catch::Benchmark::Chronometer meter) { const hic::File hf(path.string(), res); - meter.measure([&hf, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(hf, range1, range2, normalization); - } - return nnz; + meter.measure([&hf, &range]() { + return count_nnz(hf, range, range, balancing::Method::NONE()); }); }; } @@ -70,23 +51,12 @@ TEST_CASE("hic::File::fetch (cis; double)") { for (const auto& path : {test_file1, test_file2}) { for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_fp) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(1); - const auto& chrom2 = cis ? chrom1 : chroms.at(4); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), label, res)) + for (const auto& range : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), range, res)) (Catch::Benchmark::Chronometer meter) { const hic::File hf(path.string(), res); - meter.measure([&hf, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(hf, range1, range2, normalization); - } - return nnz; + meter.measure([&hf, &range]() { + return count_nnz(hf, range, range, balancing::Method::KR()); }); }; } diff --git a/benchmark/interaction_fetching/hic_trans_queries.cpp b/benchmark/interaction_fetching/hic_trans_queries.cpp index d3a1b2de..49f70466 100644 --- a/benchmark/interaction_fetching/hic_trans_queries.cpp +++ b/benchmark/interaction_fetching/hic_trans_queries.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include "./common.hpp" @@ -22,42 +24,26 @@ static const std::filesystem::path test_file2{"test/data/hic/4DNFIZ1ZVXC8.hic9"} static const std::vector resolutions{1000, 5000, 10000, 25000, 50000, 100000, 250000, 500000, 1000000, 2500000}; -static const auto w = balancing::Method::KR(); +static constexpr std::pair range_small{ + "chr2L:15,000,000-15,100,000", "chrX:10,200,000-10,300,000"}; -static const std::vector params_uint{ - {"trans; small; normalization=NONE; symmetric", false, 100e3, 100e3, 25e3, 25e3}, - {"trans; medium; normalization=NONE; symmetric", false}, - {"trans; large; normalization=NONE; symmetric", false, 5e6, 5e6, 500e3, 500e3}, -}; +static constexpr std::pair range_medium{ + "chr2L:5,000,000-6,000,000", "chrX:5,000,000-6,000,000"}; -static const std::vector params_fp{ - {"trans; small; normalization=weight; symmetric", false, 100e3, 100e3, 25e3, 25e3, 1, w}, - {"trans; medium; normalization=weight; symmetric", false, 1.0e6, 1.0e6, 250e3, 250e3, 1, w}, - {"trans; large; normalization=weight; symmetric", false, 5e6, 5e6, 500e3, 500e3, 1, w}, -}; +static constexpr std::pair range_large{ + "chr2L:15,000,000-20,000,000", "chrX:15,000,000-20,000,000"}; TEST_CASE("hic::File::fetch (trans; uint32)") { const auto chroms = hic::File(test_file1.string(), resolutions.back()).chromosomes(); for (const auto& path : {test_file1, test_file2}) { for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_uint) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(1); - const auto& chrom2 = cis ? chrom1 : chroms.at(4); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), label, res)) + for (const auto& query : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), query.first, query.second, res)) (Catch::Benchmark::Chronometer meter) { const hic::File hf(path.string(), res); - meter.measure([&hf, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(hf, range1, range2, normalization); - } - return nnz; + meter.measure([&hf, range1 = query.first, range2 = query.second]() { + return count_nnz(hf, range1, range2, balancing::Method::NONE()); }); }; } @@ -70,23 +56,12 @@ TEST_CASE("hic::File::fetch (trans; double)") { for (const auto& path : {test_file1, test_file2}) { for (const auto& res : resolutions) { - for (const auto& [label, cis, avg_height, avg_width, height_std, width_std, num_queries, - normalization_, seed] : params_fp) { - const auto normalization = normalization_; - const auto& chrom1 = chroms.at(1); - const auto& chrom2 = cis ? chrom1 : chroms.at(4); - const auto queries = generate_queries(chrom1, chrom2, num_queries, avg_height, avg_width, - height_std, width_std, seed); - - BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}bp"), label, res)) + for (const auto& query : {range_small, range_medium, range_large}) { + BENCHMARK_ADVANCED(fmt::format(FMT_STRING("{}; {}; {}bp"), query.first, query.second, res)) (Catch::Benchmark::Chronometer meter) { const hic::File hf(path.string(), res); - meter.measure([&hf, &queries, &normalization]() { - std::int64_t nnz{}; - for (const auto& [range1, range2] : queries) { - nnz += count_nnz(hf, range1, range2, normalization); - } - return nnz; + meter.measure([&hf, range1 = query.first, range2 = query.second]() { + return count_nnz(hf, range1, range2, balancing::Method::KR()); }); }; }