@@ -32,38 +32,30 @@ static constexpr std::pair<std::string_view, std::string_view> range_medium{
3232static constexpr std::pair<std::string_view, std::string_view> range_large{
3333 " chr2L:15,000,000-20,000,000" , " chrX:15,000,000-20,000,000" };
3434
35- TEST_CASE (" cooler::File::fetch (trans; uint32)" ) {
36- const auto chroms = cooler::File (fmt::format (FMT_STRING (" {}::/resolutions/{}" ),
37- test_file.string (), resolutions.back ()))
38- .chromosomes ();
39- for (const auto & res : resolutions) {
40- for (const auto & query : {range_small, range_medium, range_large}) {
41- BENCHMARK_ADVANCED (fmt::format (FMT_STRING (" {}; {}; {}bp" ), query.first , query.second , res))
42- (Catch::Benchmark::Chronometer meter) {
43- const cooler::File clr (
44- fmt::format (FMT_STRING (" {}::/resolutions/{}" ), test_file.string (), res));
45- meter.measure ([&clr, range1 = query.first , range2 = query.second ]() {
46- return count_nnz<std::uint32_t >(clr, range1, range2, balancing::Method::NONE ());
47- });
48- };
49- }
50- }
35+ template <typename N>
36+ static void run_benchmark (const std::filesystem::path& path, std::uint32_t resolution,
37+ std::string_view range1, std::string_view range2,
38+ const balancing::Method& normalization) {
39+ BENCHMARK_ADVANCED (fmt::format (FMT_STRING (" {}; {}; {}bp; {}" ), range1, range2, resolution,
40+ std::is_integral_v<N> ? " int" : " fp" ))
41+ (Catch::Benchmark::Chronometer meter) {
42+ const cooler::File clr (
43+ fmt::format (FMT_STRING (" {}::/resolutions/{}" ), path.string (), resolution));
44+ meter.measure ([&clr, &range1, &range2, &normalization]() {
45+ return count_nnz<N>(clr, range1, range2, normalization);
46+ });
47+ };
5148}
5249
53- TEST_CASE (" cooler::File::fetch (trans; double )" ) {
50+ TEST_CASE (" cooler::File::fetch (trans)" ) {
5451 const auto chroms = cooler::File (fmt::format (FMT_STRING (" {}::/resolutions/{}" ),
5552 test_file.string (), resolutions.back ()))
5653 .chromosomes ();
5754 for (const auto & res : resolutions) {
5855 for (const auto & query : {range_small, range_medium, range_large}) {
59- BENCHMARK_ADVANCED (fmt::format (FMT_STRING (" {}; {}; {}bp" ), query.first , query.second , res))
60- (Catch::Benchmark::Chronometer meter) {
61- const cooler::File clr (
62- fmt::format (FMT_STRING (" {}::/resolutions/{}" ), test_file.string (), res));
63- meter.measure ([&clr, range1 = query.first , range2 = query.second ]() {
64- return count_nnz<double >(clr, range1, range2, balancing::Method::KR ());
65- });
66- };
56+ run_benchmark<std::uint32_t >(test_file, res, query.first , query.second ,
57+ balancing::Method::NONE ());
58+ run_benchmark<double >(test_file, res, query.first , query.second , balancing::Method::KR ());
6759 }
6860 }
6961}
0 commit comments