grpc
third_party
benchmark
test
args_product_test.cc
Go to the documentation of this file.
1
#include "benchmark/benchmark.h"
2
3
#include <cassert>
4
#include <iostream>
5
#include <set>
6
#include <vector>
7
8
class
ArgsProductFixture
:
public
::benchmark::Fixture
{
9
public
:
10
ArgsProductFixture
()
11
:
expectedValues
({{0, 100, 2000, 30000},
12
{1, 15, 3, 8},
13
{1, 15, 3, 9},
14
{1, 15, 7, 8},
15
{1, 15, 7, 9},
16
{1, 15, 10, 8},
17
{1, 15, 10, 9},
18
{2, 15, 3, 8},
19
{2, 15, 3, 9},
20
{2, 15, 7, 8},
21
{2, 15, 7, 9},
22
{2, 15, 10, 8},
23
{2, 15, 10, 9},
24
{4, 5, 6, 11}}) {}
25
26
void
SetUp
(const ::benchmark::State&
state
)
BENCHMARK_OVERRIDE
{
27
std::vector<int64_t> ranges = {
state
.range(0),
state
.range(1),
28
state
.range(2),
state
.range(3)};
29
30
assert(
expectedValues
.find(ranges) !=
expectedValues
.end());
31
32
actualValues
.insert(ranges);
33
}
34
35
// NOTE: This is not TearDown as we want to check after _all_ runs are
36
// complete.
37
virtual
~ArgsProductFixture
() {
38
if
(
actualValues
!=
expectedValues
) {
39
std::cout <<
"EXPECTED\n"
;
40
for
(
auto
v
:
expectedValues
) {
41
std::cout <<
"{"
;
42
for
(
int64_t
iv :
v
) {
43
std::cout << iv <<
", "
;
44
}
45
std::cout <<
"}\n"
;
46
}
47
std::cout <<
"ACTUAL\n"
;
48
for
(
auto
v
:
actualValues
) {
49
std::cout <<
"{"
;
50
for
(
int64_t
iv :
v
) {
51
std::cout << iv <<
", "
;
52
}
53
std::cout <<
"}\n"
;
54
}
55
}
56
}
57
58
std::set<std::vector<int64_t>>
expectedValues
;
59
std::set<std::vector<int64_t>>
actualValues
;
60
};
61
62
BENCHMARK_DEFINE_F
(
ArgsProductFixture
,
Empty
)(
benchmark::State
&
state
) {
63
for
(
auto
_
:
state
) {
64
int64_t
product =
65
state
.range(0) *
state
.range(1) *
state
.range(2) *
state
.range(3);
66
for
(
int64_t
x
= 0;
x
< product;
x
++) {
67
benchmark::DoNotOptimize
(
x
);
68
}
69
}
70
}
71
72
BENCHMARK_REGISTER_F
(
ArgsProductFixture
,
Empty
)
73
->Args({0, 100, 2000, 30000})
74
->ArgsProduct({{1, 2}, {15}, {3, 7, 10}, {8, 9}})
75
->
Args
({4, 5, 6, 11});
76
77
BENCHMARK_MAIN
();
ArgsProductFixture::actualValues
std::set< std::vector< int64_t > > actualValues
Definition:
args_product_test.cc:59
ArgsProductFixture
Definition:
args_product_test.cc:8
benchmark::DoNotOptimize
BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const &value)
Definition:
benchmark/include/benchmark/benchmark.h:375
Args
Args({0, 100, 2000, 30000}) -> ArgsProduct(
Definition:
args_product_test.cc:73
benchmark::Fixture
Definition:
benchmark/include/benchmark/benchmark.h:1122
BENCHMARK_REGISTER_F
#define BENCHMARK_REGISTER_F(BaseClass, Method)
Definition:
benchmark/include/benchmark/benchmark.h:1304
int64_t
signed __int64 int64_t
Definition:
stdint-msvc2008.h:89
BENCHMARK_OVERRIDE
#define BENCHMARK_OVERRIDE
Definition:
benchmark/include/benchmark/benchmark.h:271
setup.v
v
Definition:
third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
BENCHMARK_MAIN
BENCHMARK_MAIN()
gmock_output_test._
_
Definition:
bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
x
int x
Definition:
bloaty/third_party/googletest/googlemock/test/gmock-matchers_test.cc:3610
BENCHMARK_DEFINE_F
BENCHMARK_DEFINE_F(ArgsProductFixture, Empty)(benchmark
Definition:
args_product_test.cc:62
Empty
Definition:
abseil-cpp/absl/container/internal/compressed_tuple_test.cc:33
ArgsProductFixture::ArgsProductFixture
ArgsProductFixture()
Definition:
args_product_test.cc:10
benchmark::State
Definition:
benchmark/include/benchmark/benchmark.h:503
state
Definition:
bloaty/third_party/zlib/contrib/blast/blast.c:41
ArgsProductFixture::expectedValues
std::set< std::vector< int64_t > > expectedValues
Definition:
args_product_test.cc:58
ArgsProductFixture::~ArgsProductFixture
virtual ~ArgsProductFixture()
Definition:
args_product_test.cc:37
state
static struct rpc_state state
Definition:
bad_server_response_test.cc:87
ArgsProductFixture::SetUp
void SetUp(const ::benchmark::State &state) BENCHMARK_OVERRIDE
Definition:
args_product_test.cc:26
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:43