Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F59170647
main_benchmark.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Apr 20, 07:20
Size
1 KB
Mime Type
text/x-c++
Expires
Mon, Apr 22, 07:20 (2 d)
Engine
blob
Format
Raw Data
Handle
17107282
Attached To
R12667 gbench-stream
main_benchmark.cpp
View Options
/* -------------------------------------------------------------------------- */
#include <aka_iterators.hh>
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <benchmark/benchmark.h>
#include <vector>
#include <execution>
/* -------------------------------------------------------------------------- */
using namespace akantu;
class MyFixture : public benchmark::Fixture {
using stream_type = int;
public:
void SetUp(const ::benchmark::State &state) {
auto && size = state.range(0) * 1024 / sizeof(stream_type);
A.resize(size);
B.resize(size);
auto view = enumerate(A, B);
std::for_each(std::execution::par_unseq, view.begin(), view.end(), [](auto &&data) {
std::get<1>(data) = 2. * std::get<0>(data);
std::get<2>(data) = 0.;
});
}
void TearDown(const ::benchmark::State & /*state*/) {}
std::vector<stream_type> A;
std::vector<stream_type> B;
};
BENCHMARK_DEFINE_F(MyFixture, CopyZip)(benchmark::State &st) {
auto view = zip(A, B);
std::for_each(view.begin(), view.end(),
[](auto &&data) { std::get<1>(data) = std::get<0>(data); });
for (auto _ : st) {
benchmark::DoNotOptimize(
std::for_each(std::execution::par_unseq, view.begin(), view.end(), [](auto &&data) {
std::get<1>(data) = std::get<0>(data);
}));
}
st.counters["size_kb"] =
A.size() * sizeof(typename decltype(A)::value_type) / 1024;
st.SetBytesProcessed(int64_t(st.iterations()) * A.size() * sizeof(typename decltype(A)::value_type));
}
BENCHMARK_REGISTER_F(MyFixture, CopyZip)
->RangeMultiplier(2)
->Range(2, 1 << 16);
BENCHMARK_MAIN();
Event Timeline
Log In to Comment