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
86249c57
Commit
86249c57
authored
Apr 29, 2017
by
Joao Paulo Magalhaes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Result checking: move some function definitions to source file.
parent
03b0655d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
33 deletions
+37
-33
output_test.h
test/output_test.h
+7
-33
output_test_helper.cc
test/output_test_helper.cc
+30
-0
No files found.
test/output_test.h
View file @
86249c57
...
@@ -65,6 +65,11 @@ void RunOutputTests(int argc, char* argv[]);
...
@@ -65,6 +65,11 @@ void RunOutputTests(int argc, char* argv[]);
struct
ResultsCheckerEntry
;
struct
ResultsCheckerEntry
;
typedef
std
::
function
<
void
(
ResultsCheckerEntry
const
&
)
>
ResultsCheckFn
;
typedef
std
::
function
<
void
(
ResultsCheckerEntry
const
&
)
>
ResultsCheckFn
;
// Add a function to check the (CSV) results of a benchmark. These
// functions will be called only after the output was successfully
// checked.
size_t
AddChecker
(
const
char
*
bm_name
,
ResultsCheckFn
fn
);
// Class to test the results of a benchmark.
// Class to test the results of a benchmark.
// It inspects the results by looking at the CSV output of a subscribed
// It inspects the results by looking at the CSV output of a subscribed
// benchmark.
// benchmark.
...
@@ -74,17 +79,7 @@ struct ResultsCheckerEntry {
...
@@ -74,17 +79,7 @@ struct ResultsCheckerEntry {
ResultsCheckerEntry
(
std
::
string
const
&
n
)
:
name
(
n
)
{}
ResultsCheckerEntry
(
std
::
string
const
&
n
)
:
name
(
n
)
{}
int
NumThreads
()
const
{
int
NumThreads
()
const
;
auto
pos
=
name
.
find
(
"/threads:"
);
if
(
pos
==
name
.
npos
)
return
1
;
auto
end
=
name
.
find
(
'/'
,
pos
+
9
);
std
::
stringstream
ss
;
ss
<<
name
.
substr
(
pos
+
9
,
end
);
int
num
=
1
;
ss
>>
num
;
CHECK
(
!
ss
.
fail
());
return
num
;
}
// get the real_time duration of the benchmark in seconds
// get the real_time duration of the benchmark in seconds
double
DurationRealTime
()
const
{
double
DurationRealTime
()
const
{
...
@@ -125,30 +120,9 @@ struct ResultsCheckerEntry {
...
@@ -125,30 +120,9 @@ struct ResultsCheckerEntry {
}
}
// get cpu_time or real_time in seconds
// get cpu_time or real_time in seconds
double
GetTime
(
const
char
*
which
)
const
{
double
GetTime
(
const
char
*
which
)
const
;
double
val
=
GetAs
<
double
>
(
which
);
auto
unit
=
Get
(
"time_unit"
);
CHECK
(
unit
);
if
(
*
unit
==
"ns"
)
{
return
val
*
1.e-9
;
}
else
if
(
*
unit
==
"us"
)
{
return
val
*
1.e-6
;
}
else
if
(
*
unit
==
"ms"
)
{
return
val
*
1.e-3
;
}
else
if
(
*
unit
==
"s"
)
{
return
val
;
}
else
{
CHECK
(
1
==
0
)
<<
"unknown time unit: "
<<
*
unit
;
return
0
;
}
}
};
};
// Add a function to check the (CSV) results of a benchmark. These
// functions will be called only after the output was successfully
// checked.
size_t
AddChecker
(
const
char
*
bm_name
,
ResultsCheckFn
fn
);
//----------------------------------
//----------------------------------
// Macros to help in result checking. Do not use them with arguments causing
// Macros to help in result checking. Do not use them with arguments causing
// side-effects.
// side-effects.
...
...
test/output_test_helper.cc
View file @
86249c57
...
@@ -293,6 +293,36 @@ size_t AddChecker(const char* bm_name, ResultsCheckFn fn)
...
@@ -293,6 +293,36 @@ size_t AddChecker(const char* bm_name, ResultsCheckFn fn)
return
rc
.
results
.
size
();
return
rc
.
results
.
size
();
}
}
int
ResultsCheckerEntry
::
NumThreads
()
const
{
auto
pos
=
name
.
find
(
"/threads:"
);
if
(
pos
==
name
.
npos
)
return
1
;
auto
end
=
name
.
find
(
'/'
,
pos
+
9
);
std
::
stringstream
ss
;
ss
<<
name
.
substr
(
pos
+
9
,
end
);
int
num
=
1
;
ss
>>
num
;
CHECK
(
!
ss
.
fail
());
return
num
;
}
double
ResultsCheckerEntry
::
GetTime
(
const
char
*
which
)
const
{
double
val
=
GetAs
<
double
>
(
which
);
auto
unit
=
Get
(
"time_unit"
);
CHECK
(
unit
);
if
(
*
unit
==
"ns"
)
{
return
val
*
1.e-9
;
}
else
if
(
*
unit
==
"us"
)
{
return
val
*
1.e-6
;
}
else
if
(
*
unit
==
"ms"
)
{
return
val
*
1.e-3
;
}
else
if
(
*
unit
==
"s"
)
{
return
val
;
}
else
{
CHECK
(
1
==
0
)
<<
"unknown time unit: "
<<
*
unit
;
return
0
;
}
}
// ========================================================================= //
// ========================================================================= //
// -------------------------- Public API Definitions------------------------ //
// -------------------------- Public API Definitions------------------------ //
// ========================================================================= //
// ========================================================================= //
...
...
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