FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
xtensor/benchmark/benchmark_random.cpp at master · xtensor-stack/xtensor · GitHub
xtensor-stack
xtensor
Repository navigation
Code
Issues
381
(381)
Pull requests
44
(44)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
xtensor
/
benchmark
/
benchmark_random.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (55 loc) · 2.04 KB
Breadcrumbs
xtensor
/
benchmark
/
benchmark_random.cpp
Copy path
File metadata and controls
63 lines (55 loc) · 2.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/*
**************************************************************************
* 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. *
***************************************************************************
*/
#
ifndef
BENCHMARK_RANDOM_HPP
#
define
BENCHMARK_RANDOM_HPP
#
include
<
benchmark/benchmark.h
>
#
include
"
xtensor/containers/xarray.hpp
"
#
include
"
xtensor/containers/xtensor.hpp
"
#
include
"
xtensor/core/xnoalias.hpp
"
#
include
"
xtensor/generators/xrandom.hpp
"
namespace
xt
{
namespace
random_bench
{
void
random_assign_xtensor
(benchmark::State& state)
{
for
(
auto
_ : state)
{
xtensor<
double
,
2
> result = xt::random::rand<
double
>({
20
,
20
});
benchmark::DoNotOptimize
(result.
data
());
}
}
void
random_assign_forloop
(benchmark::State& state)
{
for
(
auto
_ : state)
{
xtensor<
double
,
2
> result;
result.
resize
({
20
,
20
});
std::uniform_real_distribution<
double
>
dist
(
0
,
1
);
auto
& engine =
xt::random::get_default_random_engine
();
for
(
auto
& el : result.
storage
())
{
el =
dist
(engine);
}
benchmark::DoNotOptimize
(result.
data
());
}
}
void
random_assign_xarray
(benchmark::State& state)
{
for
(
auto
_ : state)
{
xarray<
double
> result = xt::random::rand<
double
>({
20
,
20
});
benchmark::DoNotOptimize
(result.
data
());
}
}
BENCHMARK
(random_assign_xarray);
BENCHMARK
(random_assign_xtensor);
BENCHMARK
(random_assign_forloop);
}
}
#
endif
Back
|
FazBrowse Home
|
New Git URL