Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ add_benchmark(priority_queue_push_range src/priority_queue_push_range.cpp)
add_benchmark(random_integer_generation src/random_integer_generation.cpp)
add_benchmark(remove src/remove.cpp)
add_benchmark(replace src/replace.cpp)
add_benchmark(reverse src/reverse.cpp)
add_benchmark(search src/search.cpp)
add_benchmark(search_n src/search_n.cpp)
add_benchmark(std_copy src/std_copy.cpp)
Expand Down
53 changes: 53 additions & 0 deletions benchmarks/src/reverse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <algorithm>
#include <benchmark/benchmark.h>
#include <cstdint>
#include <vector>

#include "skewed_allocator.hpp"
#include "utility.hpp"

template <class T>
void r(benchmark::State& state) {
const auto size = static_cast<size_t>(state.range(0));
auto v = random_vector<T, not_highly_aligned_allocator>(size);

for (auto _ : state) {
benchmark::DoNotOptimize(v);
std::reverse(v.begin(), v.end());
}
}

template <class T>
void rc(benchmark::State& state) {
const auto size = static_cast<size_t>(state.range(0));
auto v = random_vector<T, not_highly_aligned_allocator>(size);
std::vector<T, not_highly_aligned_allocator<T>> d(size);

for (auto _ : state) {
benchmark::DoNotOptimize(v);
std::reverse_copy(v.begin(), v.end(), d.begin());
benchmark::DoNotOptimize(d);
}
}

void common_args(auto bm) {
bm->Arg(3449);
// AVX tail tests
bm->Arg(63)->Arg(31)->Arg(15)->Arg(7);
}


BENCHMARK(r<std::uint8_t>)->Apply(common_args);
BENCHMARK(r<std::uint16_t>)->Apply(common_args);
BENCHMARK(r<std::uint32_t>)->Apply(common_args);
BENCHMARK(r<std::uint64_t>)->Apply(common_args);

BENCHMARK(rc<std::uint8_t>)->Apply(common_args);
BENCHMARK(rc<std::uint16_t>)->Apply(common_args);
BENCHMARK(rc<std::uint32_t>)->Apply(common_args);
BENCHMARK(rc<std::uint64_t>)->Apply(common_args);

BENCHMARK_MAIN();
Loading