generated from seqan/library-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin | ||
# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
hibf_benchmark (hyperloglog_benchmark.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin | ||
// SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include <benchmark/benchmark.h> // for State, Benchmark, Counter, ClobberMemory, BENCHMARK | ||
|
||
#include <random> | ||
|
||
#include <hibf/sketch/hyperloglog.hpp> | ||
|
||
static void add(benchmark::State & state) | ||
{ | ||
uint8_t const bits = static_cast<uint8_t>(state.range(0)); | ||
seqan::hibf::sketch::hyperloglog hll{bits}; | ||
for (auto _ : state) | ||
{ | ||
hll.add(23); | ||
} | ||
benchmark::DoNotOptimize(hll); | ||
} | ||
|
||
static void merge(benchmark::State & state) | ||
{ | ||
uint8_t const bits = static_cast<uint8_t>(state.range(0)); | ||
seqan::hibf::sketch::hyperloglog hll{bits}; | ||
for (auto _ : state) | ||
{ | ||
hll.merge(hll); | ||
} | ||
benchmark::DoNotOptimize(hll); | ||
} | ||
|
||
static void estimate(benchmark::State & state) | ||
{ | ||
uint8_t const bits = static_cast<uint8_t>(state.range(0)); | ||
seqan::hibf::sketch::hyperloglog hll{bits}; | ||
double estimate{}; | ||
for (auto _ : state) | ||
{ | ||
estimate = hll.estimate(); | ||
} | ||
benchmark::DoNotOptimize(hll); | ||
benchmark::DoNotOptimize(estimate); | ||
} | ||
|
||
static void merge_and_estimate(benchmark::State & state) | ||
{ | ||
uint8_t const bits = static_cast<uint8_t>(state.range(0)); | ||
seqan::hibf::sketch::hyperloglog hll{bits}; | ||
double estimate{}; | ||
for (auto _ : state) | ||
{ | ||
estimate = hll.merge_and_estimate(hll); | ||
} | ||
benchmark::DoNotOptimize(hll); | ||
benchmark::DoNotOptimize(estimate); | ||
} | ||
|
||
BENCHMARK(add)->DenseRange(5, 12, 1); | ||
BENCHMARK(merge)->DenseRange(5, 12, 1); | ||
BENCHMARK(estimate)->DenseRange(5, 12, 1); | ||
BENCHMARK(merge_and_estimate)->DenseRange(5, 12, 1); | ||
|
||
BENCHMARK_MAIN(); |