-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathbenchmark_creation.cpp
More file actions
67 lines (59 loc) · 1.98 KB
/
Copy pathbenchmark_creation.cpp
File metadata and controls
67 lines (59 loc) · 1.98 KB
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
/****************************************************************************
* Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#include <benchmark/benchmark.h>
#include "xtensor/containers/xarray.hpp"
#include "xtensor/containers/xfixed.hpp"
#include "xtensor/containers/xtensor.hpp"
#include "xtensor/generators/xbuilder.hpp"
namespace xt
{
void benchmark_empty(benchmark::State& state)
{
for (auto _ : state)
{
auto e = xt::empty<double>({5, 5});
}
}
template <class T>
void benchmark_from_shape(benchmark::State& state)
{
for (auto _ : state)
{
T e = T::from_shape({5, 5});
}
}
template <class T>
void benchmark_creation(benchmark::State& state)
{
for (auto _ : state)
{
T e(typename T::shape_type({5, 5}));
}
}
void benchmark_empty_to_xtensor(benchmark::State& state)
{
for (auto _ : state)
{
xtensor<double, 2> e = xt::empty<double>({5, 5});
}
}
void benchmark_empty_to_xarray(benchmark::State& state)
{
for (auto _ : state)
{
xarray<double> e = xt::empty<double>({5, 5});
}
}
BENCHMARK(benchmark_empty);
BENCHMARK(benchmark_empty_to_xtensor);
BENCHMARK(benchmark_empty_to_xarray);
BENCHMARK_TEMPLATE(benchmark_from_shape, xarray<double>);
BENCHMARK_TEMPLATE(benchmark_from_shape, xtensor<double, 2>);
BENCHMARK_TEMPLATE(benchmark_creation, xarray<double>);
BENCHMARK_TEMPLATE(benchmark_creation, xtensor<double, 2>);
}