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
43ef1744
Commit
43ef1744
authored
May 23, 2016
by
Ismael
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor names
parent
d577987f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
21 deletions
+21
-21
reporter.cc
src/reporter.cc
+17
-17
complexity_test.cc
test/complexity_test.cc
+4
-4
No files found.
src/reporter.cc
View file @
43ef1744
...
...
@@ -84,48 +84,48 @@ void BenchmarkReporter::ComputeBigO(
Run
*
big_o
,
Run
*
rms
)
{
CHECK
(
reports
.
size
()
>=
2
)
<<
"Cannot compute asymptotic complexity for less than 2 reports"
;
// Accumulators.
std
::
vector
<
int
>
N
;
std
::
vector
<
double
>
RealT
ime
;
std
::
vector
<
double
>
CpuT
ime
;
std
::
vector
<
int
>
n
;
std
::
vector
<
double
>
real_t
ime
;
std
::
vector
<
double
>
cpu_t
ime
;
// Populate the accumulators.
for
(
const
Run
&
run
:
reports
)
{
N
.
push_back
(
run
.
arg1
);
RealT
ime
.
push_back
(
run
.
real_accumulated_time
/
run
.
iterations
);
CpuT
ime
.
push_back
(
run
.
cpu_accumulated_time
/
run
.
iterations
);
n
.
push_back
(
run
.
arg1
);
real_t
ime
.
push_back
(
run
.
real_accumulated_time
/
run
.
iterations
);
cpu_t
ime
.
push_back
(
run
.
cpu_accumulated_time
/
run
.
iterations
);
}
LeastSq
result
Cpu
=
MinimalLeastSq
(
N
,
CpuT
ime
,
reports
[
0
].
complexity
);
LeastSq
result
_cpu
=
MinimalLeastSq
(
n
,
cpu_t
ime
,
reports
[
0
].
complexity
);
// result
Cpu.complexity is passed as parameter to resultR
eal because in case
// result
_cpu.complexity is passed as parameter to result_r
eal because in case
// reports[0].complexity is oAuto, the noise on the measured data could make
// the best fit function of Cpu and Real differ. In order to solve this, we take
// the best fitting function for the Cpu, and apply it to Real data.
LeastSq
result
Real
=
MinimalLeastSq
(
N
,
RealTime
,
resultC
pu
.
complexity
);
LeastSq
result
_real
=
MinimalLeastSq
(
n
,
real_time
,
result_c
pu
.
complexity
);
std
::
string
benchmark_name
=
reports
[
0
].
benchmark_name
.
substr
(
0
,
reports
[
0
].
benchmark_name
.
find
(
'/'
));
// Get the data from the accumulator to BenchmarkReporter::Run's.
big_o
->
benchmark_name
=
benchmark_name
+
"_BigO"
;
big_o
->
iterations
=
0
;
big_o
->
real_accumulated_time
=
result
R
eal
.
coef
;
big_o
->
cpu_accumulated_time
=
result
C
pu
.
coef
;
big_o
->
real_accumulated_time
=
result
_r
eal
.
coef
;
big_o
->
cpu_accumulated_time
=
result
_c
pu
.
coef
;
big_o
->
report_big_o
=
true
;
big_o
->
complexity
=
result
C
pu
.
complexity
;
big_o
->
complexity
=
result
_c
pu
.
complexity
;
double
multiplier
;
const
char
*
time
L
abel
;
std
::
tie
(
time
L
abel
,
multiplier
)
=
GetTimeUnitAndMultiplier
(
reports
[
0
].
time_unit
);
const
char
*
time
_l
abel
;
std
::
tie
(
time
_l
abel
,
multiplier
)
=
GetTimeUnitAndMultiplier
(
reports
[
0
].
time_unit
);
// Only add label to mean/stddev if it is same for all runs
big_o
->
report_label
=
reports
[
0
].
report_label
;
rms
->
benchmark_name
=
benchmark_name
+
"_RMS"
;
rms
->
report_label
=
big_o
->
report_label
;
rms
->
iterations
=
0
;
rms
->
real_accumulated_time
=
result
R
eal
.
rms
/
multiplier
;
rms
->
cpu_accumulated_time
=
result
C
pu
.
rms
/
multiplier
;
rms
->
real_accumulated_time
=
result
_r
eal
.
rms
/
multiplier
;
rms
->
cpu_accumulated_time
=
result
_c
pu
.
rms
/
multiplier
;
rms
->
report_rms
=
true
;
rms
->
complexity
=
result
C
pu
.
complexity
;
rms
->
complexity
=
result
_c
pu
.
complexity
;
}
std
::
string
BenchmarkReporter
::
GetBigO
(
BigO
complexity
)
{
...
...
test/complexity_test.cc
View file @
43ef1744
...
...
@@ -31,9 +31,9 @@ BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity(benchmark::o1);
static
void
BM_Complexity_O_N
(
benchmark
::
State
&
state
)
{
auto
v
=
ConstructRandomVector
(
state
.
range_x
());
const
int
item
NotInV
ector
=
state
.
range_x
()
*
2
;
// Test worst case scenario (item not in vector)
const
int
item
_not_in_v
ector
=
state
.
range_x
()
*
2
;
// Test worst case scenario (item not in vector)
while
(
state
.
KeepRunning
())
{
benchmark
::
DoNotOptimize
(
std
::
find
(
v
.
begin
(),
v
.
end
(),
item
NotInV
ector
));
benchmark
::
DoNotOptimize
(
std
::
find
(
v
.
begin
(),
v
.
end
(),
item
_not_in_v
ector
));
}
}
BENCHMARK
(
BM_Complexity_O_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
(
benchmark
::
oN
);
...
...
@@ -71,9 +71,9 @@ BENCHMARK(BM_Complexity_O_N_Cubed) -> DenseRange(1, 8) -> Complexity(benchmark::
static
void
BM_Complexity_O_log_N
(
benchmark
::
State
&
state
)
{
auto
m
=
ConstructRandomMap
(
state
.
range_x
());
const
int
item
NotInV
ector
=
state
.
range_x
()
*
2
;
// Test worst case scenario (item not in vector)
const
int
item
_not_in_v
ector
=
state
.
range_x
()
*
2
;
// Test worst case scenario (item not in vector)
while
(
state
.
KeepRunning
())
{
benchmark
::
DoNotOptimize
(
m
.
find
(
item
NotInV
ector
));
benchmark
::
DoNotOptimize
(
m
.
find
(
item
_not_in_v
ector
));
}
}
BENCHMARK
(
BM_Complexity_O_log_N
)
...
...
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