File: container_push_back_benchmark.cpp

package info (click to toggle)
seqan3 3.0.2%2Bds-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,052 kB
  • sloc: cpp: 144,641; makefile: 1,288; ansic: 294; sh: 228; xml: 217; javascript: 50; python: 27; php: 25
file content (106 lines) | stat: -rw-r--r-- 4,883 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// -----------------------------------------------------------------------------------------------------
// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
// -----------------------------------------------------------------------------------------------------

#include <deque>
#include <list>
#include <vector>

#include <benchmark/benchmark.h>

#include <seqan3/alphabet/all.hpp>
#include <seqan3/range/container/all.hpp>

template <typename t>
using sdsl_int_vec = sdsl::int_vector<sizeof(t) * 8>;

template <typename t>
using small_vec = seqan3::small_vector<t, 10'000>;

// ============================================================================
//  push_back
// ============================================================================

template <template <typename> typename container_t, typename alphabet_t>
void push_back(benchmark::State & state)
{
    alphabet_t a{};

    for (auto _ : state)
    {
        container_t<alphabet_t> c;
        for (size_t i = 0; i < 10'000; ++i)
            c.push_back(a);
        a = c.back();
    }

    state.counters["sizeof"] = sizeof(alphabet_t);
    if constexpr (seqan3::alphabet<alphabet_t>)
        state.counters["alph_size"] = seqan3::alphabet_size<alphabet_t>;
}

BENCHMARK_TEMPLATE(push_back, std::vector, char);
BENCHMARK_TEMPLATE(push_back, std::vector, uint8_t);
BENCHMARK_TEMPLATE(push_back, std::vector, uint16_t);
BENCHMARK_TEMPLATE(push_back, std::vector, uint32_t);
BENCHMARK_TEMPLATE(push_back, std::vector, uint64_t);
BENCHMARK_TEMPLATE(push_back, std::vector, seqan3::gap);
BENCHMARK_TEMPLATE(push_back, std::vector, seqan3::dna4);
BENCHMARK_TEMPLATE(push_back, std::vector, seqan3::gapped<seqan3::dna4>);
BENCHMARK_TEMPLATE(push_back, std::vector, seqan3::dna15);
BENCHMARK_TEMPLATE(push_back, std::vector, seqan3::aa27);
BENCHMARK_TEMPLATE(push_back, std::vector, seqan3::alphabet_variant<char, seqan3::dna4>);

BENCHMARK_TEMPLATE(push_back, std::deque, char);
BENCHMARK_TEMPLATE(push_back, std::deque, uint8_t);
BENCHMARK_TEMPLATE(push_back, std::deque, uint16_t);
BENCHMARK_TEMPLATE(push_back, std::deque, uint32_t);
BENCHMARK_TEMPLATE(push_back, std::deque, uint64_t);
BENCHMARK_TEMPLATE(push_back, std::deque, seqan3::gap);
BENCHMARK_TEMPLATE(push_back, std::deque, seqan3::dna4);
BENCHMARK_TEMPLATE(push_back, std::deque, seqan3::gapped<seqan3::dna4>);
BENCHMARK_TEMPLATE(push_back, std::deque, seqan3::dna15);
BENCHMARK_TEMPLATE(push_back, std::deque, seqan3::aa27);
BENCHMARK_TEMPLATE(push_back, std::deque, seqan3::alphabet_variant<char, seqan3::dna4>);

BENCHMARK_TEMPLATE(push_back, std::list, char);
BENCHMARK_TEMPLATE(push_back, std::list, uint8_t);
BENCHMARK_TEMPLATE(push_back, std::list, uint16_t);
BENCHMARK_TEMPLATE(push_back, std::list, uint32_t);
BENCHMARK_TEMPLATE(push_back, std::list, uint64_t);
BENCHMARK_TEMPLATE(push_back, std::list, seqan3::gap);
BENCHMARK_TEMPLATE(push_back, std::list, seqan3::dna4);
BENCHMARK_TEMPLATE(push_back, std::list, seqan3::gapped<seqan3::dna4>);
BENCHMARK_TEMPLATE(push_back, std::list, seqan3::dna15);
BENCHMARK_TEMPLATE(push_back, std::list, seqan3::aa27);
BENCHMARK_TEMPLATE(push_back, std::list, seqan3::alphabet_variant<char, seqan3::dna4>);

BENCHMARK_TEMPLATE(push_back, sdsl_int_vec, uint8_t);
BENCHMARK_TEMPLATE(push_back, sdsl_int_vec, uint16_t);
BENCHMARK_TEMPLATE(push_back, sdsl_int_vec, uint32_t);
BENCHMARK_TEMPLATE(push_back, sdsl_int_vec, uint64_t);

BENCHMARK_TEMPLATE(push_back, seqan3::bitcompressed_vector, char);
BENCHMARK_TEMPLATE(push_back, seqan3::bitcompressed_vector, seqan3::gap);
BENCHMARK_TEMPLATE(push_back, seqan3::bitcompressed_vector, seqan3::dna4);
BENCHMARK_TEMPLATE(push_back, seqan3::bitcompressed_vector, seqan3::gapped<seqan3::dna4>);
BENCHMARK_TEMPLATE(push_back, seqan3::bitcompressed_vector, seqan3::dna15);
BENCHMARK_TEMPLATE(push_back, seqan3::bitcompressed_vector, seqan3::aa27);
BENCHMARK_TEMPLATE(push_back, seqan3::bitcompressed_vector, seqan3::alphabet_variant<char, seqan3::dna4>);

BENCHMARK_TEMPLATE(push_back, small_vec, char);
BENCHMARK_TEMPLATE(push_back, small_vec, seqan3::gap);
BENCHMARK_TEMPLATE(push_back, small_vec, seqan3::dna4);
BENCHMARK_TEMPLATE(push_back, small_vec, seqan3::gapped<seqan3::dna4>);
BENCHMARK_TEMPLATE(push_back, small_vec, seqan3::dna15);
BENCHMARK_TEMPLATE(push_back, small_vec, seqan3::aa27);
BENCHMARK_TEMPLATE(push_back, small_vec, seqan3::alphabet_variant<char, seqan3::dna4>);

// ============================================================================
//  run
// ============================================================================

BENCHMARK_MAIN();