protobuf
third_party
benchmark
src
reporter.cc
Go to the documentation of this file.
1
// Copyright 2015 Google Inc. All rights reserved.
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
// http://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 "
benchmark/benchmark.h
"
16
#include "
timers.h
"
17
18
#include <cstdlib>
19
20
#include <iostream>
21
#include <tuple>
22
#include <vector>
23
24
#include "
check.h
"
25
#include "
stat.h
"
26
27
namespace
benchmark
{
28
29
BenchmarkReporter::BenchmarkReporter
()
30
: output_stream_(&
std
::cout), error_stream_(&
std
::cerr) {}
31
32
BenchmarkReporter::~BenchmarkReporter
() {}
33
34
void
BenchmarkReporter::PrintBasicContext
(std::ostream *out,
35
Context
const
&context) {
36
CHECK
(out) <<
"cannot be null"
;
37
auto
&Out = *out;
38
39
Out <<
"Run on ("
<< context.
num_cpus
<<
" X "
<< context.
mhz_per_cpu
40
<<
" MHz CPU "
<< ((context.
num_cpus
> 1) ?
"s"
:
""
) <<
")\n"
;
41
42
Out <<
LocalDateTimeString
() <<
"\n"
;
43
44
if
(context.
cpu_scaling_enabled
) {
45
Out <<
"***WARNING*** CPU scaling is enabled, the benchmark "
46
"real time measurements may be noisy and will incur extra "
47
"overhead.\n"
;
48
}
49
50
#ifndef NDEBUG
51
Out <<
"***WARNING*** Library was built as DEBUG. Timings may be "
52
"affected.\n"
;
53
#endif
54
}
55
56
double
BenchmarkReporter::Run::GetAdjustedRealTime
()
const
{
57
double
new_time =
real_accumulated_time
*
GetTimeUnitMultiplier
(
time_unit
);
58
if
(
iterations
!= 0) new_time /=
static_cast<
double
>
(
iterations
);
59
return
new_time;
60
}
61
62
double
BenchmarkReporter::Run::GetAdjustedCPUTime
()
const
{
63
double
new_time = cpu_accumulated_time *
GetTimeUnitMultiplier
(time_unit);
64
if
(iterations != 0) new_time /=
static_cast<
double
>
(iterations);
65
return
new_time;
66
}
67
68
}
// end namespace benchmark
check.h
benchmark
Definition:
benchmark.h:241
benchmark::BenchmarkReporter::BenchmarkReporter
BenchmarkReporter()
Definition:
reporter.cc:29
benchmark::BenchmarkReporter::~BenchmarkReporter
virtual ~BenchmarkReporter()
Definition:
reporter.cc:32
benchmark::BenchmarkReporter::Run::GetAdjustedCPUTime
double GetAdjustedCPUTime() const
Definition:
reporter.cc:62
benchmark::BenchmarkReporter::PrintBasicContext
static void PrintBasicContext(std::ostream *out, Context const &context)
Definition:
reporter.cc:34
CHECK
#define CHECK(x)
Definition:
php/ext/google/protobuf/upb.c:8393
benchmark::BenchmarkReporter::Context::mhz_per_cpu
double mhz_per_cpu
Definition:
benchmark.h:1010
stat.h
timers.h
benchmark::BenchmarkReporter::Run::real_accumulated_time
double real_accumulated_time
Definition:
benchmark.h:1041
benchmark::BenchmarkReporter::Run::time_unit
TimeUnit time_unit
Definition:
benchmark.h:1040
std
benchmark::BenchmarkReporter::Run::GetAdjustedRealTime
double GetAdjustedRealTime() const
Definition:
reporter.cc:56
benchmark::GetTimeUnitMultiplier
double GetTimeUnitMultiplier(TimeUnit unit)
Definition:
benchmark.h:1196
benchmark::BenchmarkReporter::Context::num_cpus
int num_cpus
Definition:
benchmark.h:1009
benchmark::BenchmarkReporter::Context
Definition:
benchmark.h:1008
benchmark.h
benchmark::LocalDateTimeString
std::string LocalDateTimeString()
Definition:
timers.cc:210
benchmark::BenchmarkReporter::Context::cpu_scaling_enabled
bool cpu_scaling_enabled
Definition:
benchmark.h:1011
benchmark::BenchmarkReporter::Run::iterations
int64_t iterations
Definition:
benchmark.h:1039
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:58