Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inline naive_kmer_hash and naive_miniser_hash #2967

Merged
merged 2 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 0 additions & 102 deletions test/include/seqan3/test/performance/naive_kmer_hash.hpp

This file was deleted.

15 changes: 13 additions & 2 deletions test/performance/search/views/view_kmer_hash_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <seqan3/alphabet/nucleotide/dna4.hpp>
#include <seqan3/search/views/kmer_hash.hpp>
#include <seqan3/test/performance/sequence_generator.hpp>
#include <seqan3/test/performance/naive_kmer_hash.hpp>
#include <seqan3/test/performance/units.hpp>

#ifdef SEQAN3_HAS_SEQAN2
Expand Down Expand Up @@ -104,8 +103,20 @@ static void naive_kmer_hash(benchmark::State & state)

for (auto _ : state)
{
for (auto h : seq | seqan3::views::naive_kmer_hash(k))
// creates a initial subrange covering exactly 'k-1' characters
auto subrange_begin = begin(seq);
auto subrange_end = std::ranges::next(subrange_begin, k - 1, end(seq));

// slide over the range
while (subrange_end != end(seq))
{
++subrange_end; // extend to 'k' characters
auto r = std::ranges::subrange{subrange_begin, subrange_end};
auto h = std::hash<decltype(r)>{}(r);
++subrange_begin; // move front forward, back to 'k-1' characters range

benchmark::DoNotOptimize(sum += h);
}
}

// prevent complete optimisation
Expand Down