grpc
third_party
abseil-cpp
absl
container
abseil-cpp/absl/container/fixed_array_benchmark.cc
Go to the documentation of this file.
1
// Copyright 2019 The Abseil Authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <stddef.h>
16
17
#include <string>
18
19
#include "benchmark/benchmark.h"
20
#include "absl/container/fixed_array.h"
21
22
namespace
{
23
24
// For benchmarking -- simple class with constructor and destructor that
25
// set an int to a constant..
26
class
SimpleClass {
27
public
:
28
SimpleClass() :
i
(3) {}
29
~SimpleClass() {
i
= 0; }
30
31
private
:
32
int
i
;
33
};
34
35
template
<
typename
C,
size_t
stack_size>
36
void
BM_FixedArray(
benchmark::State
&
state
) {
37
const
int
size
=
state
.range(0);
38
for
(
auto
_
:
state
) {
39
absl::FixedArray<C, stack_size>
fa(
size
);
40
benchmark::DoNotOptimize
(fa.data());
41
}
42
}
43
BENCHMARK_TEMPLATE
(BM_FixedArray,
char
,
absl::kFixedArrayUseDefault
)
44
->Range(0, 1 << 16);
45
BENCHMARK_TEMPLATE
(BM_FixedArray,
char
, 0)->Range(0, 1 << 16);
46
BENCHMARK_TEMPLATE
(BM_FixedArray,
char
, 1)->Range(0, 1 << 16);
47
BENCHMARK_TEMPLATE
(BM_FixedArray,
char
, 16)->Range(0, 1 << 16);
48
BENCHMARK_TEMPLATE
(BM_FixedArray,
char
, 256)->Range(0, 1 << 16);
49
BENCHMARK_TEMPLATE
(BM_FixedArray,
char
, 65536)->Range(0, 1 << 16);
50
51
BENCHMARK_TEMPLATE
(BM_FixedArray, SimpleClass,
absl::kFixedArrayUseDefault
)
52
->Range(0, 1 << 16);
53
BENCHMARK_TEMPLATE
(BM_FixedArray, SimpleClass, 0)->Range(0, 1 << 16);
54
BENCHMARK_TEMPLATE
(BM_FixedArray, SimpleClass, 1)->Range(0, 1 << 16);
55
BENCHMARK_TEMPLATE
(BM_FixedArray, SimpleClass, 16)->Range(0, 1 << 16);
56
BENCHMARK_TEMPLATE
(BM_FixedArray, SimpleClass, 256)->Range(0, 1 << 16);
57
BENCHMARK_TEMPLATE
(BM_FixedArray, SimpleClass, 65536)->Range(0, 1 << 16);
58
59
BENCHMARK_TEMPLATE
(BM_FixedArray,
std::string
,
absl::kFixedArrayUseDefault
)
60
->Range(0, 1 << 16);
61
BENCHMARK_TEMPLATE
(BM_FixedArray,
std::string
, 0)->Range(0, 1 << 16);
62
BENCHMARK_TEMPLATE
(BM_FixedArray,
std::string
, 1)->Range(0, 1 << 16);
63
BENCHMARK_TEMPLATE
(BM_FixedArray,
std::string
, 16)->Range(0, 1 << 16);
64
BENCHMARK_TEMPLATE
(BM_FixedArray,
std::string
, 256)->Range(0, 1 << 16);
65
BENCHMARK_TEMPLATE
(BM_FixedArray,
std::string
, 65536)->Range(0, 1 << 16);
66
67
}
// namespace
testing::internal::string
::std::string string
Definition:
bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
benchmark::DoNotOptimize
BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const &value)
Definition:
benchmark/include/benchmark/benchmark.h:375
absl::kFixedArrayUseDefault
constexpr static ABSL_NAMESPACE_BEGIN auto kFixedArrayUseDefault
Definition:
abseil-cpp/absl/container/fixed_array.h:56
BENCHMARK_TEMPLATE
#define BENCHMARK_TEMPLATE(n, a)
Definition:
benchmark/include/benchmark/benchmark.h:1231
gmock_output_test._
_
Definition:
bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
benchmark::State
Definition:
benchmark/include/benchmark/benchmark.h:503
state
Definition:
bloaty/third_party/zlib/contrib/blast/blast.c:41
size
voidpf void uLong size
Definition:
bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
absl::FixedArray
Definition:
abseil-cpp/absl/container/fixed_array.h:78
i
uint64_t i
Definition:
abseil-cpp/absl/container/btree_benchmark.cc:230
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:23