Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
b5082bbd
Commit
b5082bbd
authored
Nov 13, 2018
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'report_loadavg' of
https://github.com/atdt/benchmark
into atdt-report_loadavg
parents
bb15a4e3
e1150aca
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
3 deletions
+46
-3
AUTHORS
AUTHORS
+1
-0
CONTRIBUTORS
CONTRIBUTORS
+1
-0
benchmark.h
include/benchmark/benchmark.h
+1
-0
json_reporter.cc
src/json_reporter.cc
+6
-0
reporter.cc
src/reporter.cc
+9
-0
sysinfo.cc
src/sysinfo.cc
+20
-1
reporter_output_test.cc
test/reporter_output_test.cc
+8
-2
No files found.
AUTHORS
View file @
b5082bbd
...
...
@@ -36,6 +36,7 @@ Maxim Vafin <maxvafin@gmail.com>
MongoDB Inc.
Nick Hutchinson <nshutchinson@gmail.com>
Oleksandr Sochka <sasha.sochka@gmail.com>
Ori Livneh <ori.livneh@gmail.com>
Paul Redmond <paul.redmond@gmail.com>
Radoslav Yovchev <radoslav.tm@gmail.com>
Roman Lebedev <lebedev.ri@gmail.com>
...
...
CONTRIBUTORS
View file @
b5082bbd
...
...
@@ -50,6 +50,7 @@ Matt Clarkson <mattyclarkson@gmail.com>
Maxim Vafin <maxvafin@gmail.com>
Nick Hutchinson <nshutchinson@gmail.com>
Oleksandr Sochka <sasha.sochka@gmail.com>
Ori Livneh <ori.livneh@gmail.com>
Pascal Leroy <phl@google.com>
Paul Redmond <paul.redmond@gmail.com>
Pierre Phaneuf <pphaneuf@google.com>
...
...
include/benchmark/benchmark.h
View file @
b5082bbd
...
...
@@ -1284,6 +1284,7 @@ struct CPUInfo {
double
cycles_per_second
;
std
::
vector
<
CacheInfo
>
caches
;
bool
scaling_enabled
;
std
::
vector
<
double
>
load_avg
;
static
const
CPUInfo
&
Get
();
...
...
src/json_reporter.cc
View file @
b5082bbd
...
...
@@ -116,6 +116,12 @@ bool JSONReporter::ReportContext(const Context& context) {
}
indent
=
std
::
string
(
4
,
' '
);
out
<<
indent
<<
"],
\n
"
;
out
<<
indent
<<
"
\"
load_avg
\"
: ["
;
for
(
auto
it
=
info
.
load_avg
.
begin
();
it
!=
info
.
load_avg
.
end
();)
{
out
<<
*
it
++
;
if
(
it
!=
info
.
load_avg
.
end
())
out
<<
","
;
}
out
<<
"],
\n
"
;
#if defined(NDEBUG)
const
char
build_type
[]
=
"release"
;
...
...
src/reporter.cc
View file @
b5082bbd
...
...
@@ -22,6 +22,7 @@
#include <vector>
#include "check.h"
#include "string_util.h"
namespace
benchmark
{
...
...
@@ -54,6 +55,14 @@ void BenchmarkReporter::PrintBasicContext(std::ostream *out,
Out
<<
"
\n
"
;
}
}
if
(
!
info
.
load_avg
.
empty
())
{
Out
<<
"Load Average: "
;
for
(
auto
It
=
info
.
load_avg
.
begin
();
It
!=
info
.
load_avg
.
end
();)
{
Out
<<
StrFormat
(
"%.2f"
,
*
It
++
);
if
(
It
!=
info
.
load_avg
.
end
())
Out
<<
", "
;
}
Out
<<
"
\n
"
;
}
if
(
info
.
scaling_enabled
)
{
Out
<<
"***WARNING*** CPU scaling is enabled, the benchmark "
...
...
src/sysinfo.cc
View file @
b5082bbd
...
...
@@ -577,6 +577,24 @@ double GetCPUCyclesPerSecond() {
return
static_cast
<
double
>
(
cycleclock
::
Now
()
-
start_ticks
);
}
std
::
vector
<
double
>
GetLoadAvg
()
{
#if defined BENCHMARK_OS_FREEBSD || defined(BENCHMARK_OS_LINUX) || \
defined BENCHMARK_OS_MACOSX || defined BENCHMARK_OS_NETBSD || \
defined BENCHMARK_OS_OPENBSD
constexpr
int
kMaxSamples
=
3
;
std
::
vector
<
double
>
res
(
kMaxSamples
,
0.0
);
const
int
nelem
=
getloadavg
(
res
.
data
(),
kMaxSamples
);
if
(
nelem
<
1
)
{
res
.
clear
();
}
else
{
res
.
resize
(
nelem
);
}
return
res
;
#else
return
{};
#endif
}
}
// end namespace
const
CPUInfo
&
CPUInfo
::
Get
()
{
...
...
@@ -588,6 +606,7 @@ CPUInfo::CPUInfo()
:
num_cpus
(
GetNumCPUs
()),
cycles_per_second
(
GetCPUCyclesPerSecond
()),
caches
(
GetCacheSizes
()),
scaling_enabled
(
CpuScalingEnabled
(
num_cpus
))
{}
scaling_enabled
(
CpuScalingEnabled
(
num_cpus
)),
load_avg
(
GetLoadAvg
())
{}
}
// end namespace benchmark
test/reporter_output_test.cc
View file @
b5082bbd
...
...
@@ -29,7 +29,8 @@ static int AddContextCases() {
{
"
\"
mhz_per_cpu
\"
: %float,$"
,
MR_Next
},
{
"
\"
cpu_scaling_enabled
\"
: "
,
MR_Next
},
{
"
\"
caches
\"
:
\\
[$"
,
MR_Next
}});
auto
const
&
Caches
=
benchmark
::
CPUInfo
::
Get
().
caches
;
auto
const
&
Info
=
benchmark
::
CPUInfo
::
Get
();
auto
const
&
Caches
=
Info
.
caches
;
if
(
!
Caches
.
empty
())
{
AddCases
(
TC_ConsoleErr
,
{{
"CPU Caches:$"
,
MR_Next
}});
}
...
...
@@ -46,8 +47,13 @@ static int AddContextCases() {
{
"
\"
num_sharing
\"
: %int$"
,
MR_Next
},
{
"}[,]{0,1}$"
,
MR_Next
}});
}
AddCases
(
TC_JSONOut
,
{{
"],$"
}});
auto
const
&
LoadAvg
=
Info
.
load_avg
;
if
(
!
LoadAvg
.
empty
())
{
AddCases
(
TC_ConsoleErr
,
{{
"Load Average: (%float, ){0,2}%float$"
,
MR_Next
}});
}
AddCases
(
TC_JSONOut
,
{{
"
\"
load_avg
\"
:
\\
[(%float,?){0,3}],$"
,
MR_Next
}});
return
0
;
}
int
dummy_register
=
AddContextCases
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment