Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
las3_pub
/
predictable_parallel_patterns
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
616964f6
authored
May 29, 2020
by
FritzFlorian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sync benchmark runner.
parent
54dae64f
Pipeline
#1495
failed with stages
in 56 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
6 deletions
+84
-6
extern/benchmark_runner/benchmark_runner.h
+84
-6
No files found.
extern/benchmark_runner/benchmark_runner.h
View file @
616964f6
...
...
@@ -10,6 +10,14 @@
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#include <thread>
#include <map>
#include <tuple>
#include <unistd.h>
#include <string>
#include <fstream>
#include <sstream>
using
namespace
std
;
...
...
@@ -21,9 +29,16 @@ class benchmark_runner {
chrono
::
steady_clock
::
time_point
last_start_time_
;
vector
<
long
>
times_
;
map
<
string
,
vector
<
long
>>
custom_stats_
;
void
print_statistics
()
{
long
time_sum
=
std
::
accumulate
(
times_
.
begin
(),
times_
.
end
(),
0l
);
cout
<<
"Average Runtime (us): "
<<
(
time_sum
/
times_
.
size
())
<<
endl
;
for
(
auto
&
iter
:
custom_stats_
)
{
long
custom_stat_sum
=
std
::
accumulate
(
iter
.
second
.
begin
(),
iter
.
second
.
end
(),
0l
);
cout
<<
"Average "
<<
iter
.
first
<<
": "
<<
(
custom_stat_sum
/
times_
.
size
())
<<
endl
;
}
}
inline
bool
file_exists
(
const
std
::
string
&
name
)
{
...
...
@@ -32,7 +47,7 @@ class benchmark_runner {
}
public
:
benchmark_runner
(
string
csv_path
,
string
csv_name
,
int
num_measurements
=
10000
)
:
csv_path_
{
std
::
move
(
csv_path
)},
benchmark_runner
(
string
csv_path
,
string
csv_name
)
:
csv_path_
{
std
::
move
(
csv_path
)},
csv_name_
{
std
::
move
(
csv_name
)},
times_
{}
{
string
command
=
"mkdir -p "
+
csv_path_
;
...
...
@@ -41,8 +56,44 @@ class benchmark_runner {
cout
<<
"Error while creating directory!"
<<
endl
;
exit
(
1
);
}
}
/**
* Queries the pages used by the current process.
* Splits between private and shared pages.
*
* @return Tuple(private_pages, shared_pages) used by the process.
*/
static
std
::
pair
<
unsigned
long
,
unsigned
long
>
query_process_memory_pages
()
{
pid_t
my_pid
=
getpid
();
std
::
ostringstream
proc_stats_path_builder
;
proc_stats_path_builder
<<
"/proc/"
<<
my_pid
<<
"/smaps_rollup"
;
std
::
string
proc_stats_path
=
proc_stats_path_builder
.
str
();
std
::
ifstream
proc_stats_file
{
proc_stats_path
};
std
::
string
line
;
unsigned
long
total_shared
=
0
;
unsigned
long
total_private
=
0
;
while
(
std
::
getline
(
proc_stats_file
,
line
))
{
std
::
stringstream
line_input
(
line
);
std
::
string
type
;
unsigned
long
size
;
line_input
>>
type
>>
size
;
if
(
type
.
find
(
"Shared"
)
!=
std
::
string
::
npos
)
{
total_shared
+=
size
;
}
if
(
type
.
find
(
"Private"
)
!=
std
::
string
::
npos
)
{
total_private
+=
size
;
}
}
times_
.
reserve
(
num_measurements
);
return
std
::
make_pair
(
total_private
,
total_shared
);
}
void
add_custom_stats_field
(
const
string
name
)
{
custom_stats_
.
insert
({
name
,
{}});
}
static
void
read_args
(
int
argc
,
char
**
argv
,
int
&
num_threads
,
string
&
path
)
{
...
...
@@ -65,22 +116,35 @@ class benchmark_runner {
auto
end_time
=
chrono
::
steady_clock
::
now
();
long
time
=
chrono
::
duration_cast
<
chrono
::
microseconds
>
(
end_time
-
last_start_time_
).
count
();
times_
.
emplace_back
(
time
);
for
(
auto
&
iter
:
custom_stats_
)
{
iter
.
second
.
emplace_back
(
0
);
}
}
void
store_custom_stat
(
const
string
&
name
,
long
value
)
{
auto
&
stat_vector
=
custom_stats_
[
name
];
stat_vector
[
stat_vector
.
size
()
-
1
]
=
value
;
}
void
run_iterations
(
int
count
,
const
function
<
void
(
void
)
>
measure
,
int
warmup_count
,
const
function
<
void
(
void
)
>
prepare
=
[]()
{})
{
const
function
<
void
(
void
)
>
prepare
=
[]()
{},
const
function
<
void
(
void
)
>
finish
=
[]()
{})
{
for
(
int
i
=
0
;
i
<
warmup_count
;
i
++
)
{
prepare
();
measure
();
}
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
using
namespace
std
::
literals
;
this_thread
::
sleep_for
(
100u
s
);
prepare
();
start_iteration
();
measure
();
end_iteration
();
finish
();
}
}
...
...
@@ -94,15 +158,29 @@ class benchmark_runner {
{
// Scope for output file
ofstream
o
(
full_filename
,
std
::
fstream
::
out
|
std
::
fstream
::
app
);
if
(
write_header
)
{
o
<<
"runtime_us"
<<
endl
;
o
<<
"runtime_us"
;
for
(
auto
&
iter
:
custom_stats_
)
{
o
<<
";"
<<
iter
.
first
;
}
o
<<
endl
;
}
for
(
auto
time
:
times_
)
{
o
<<
time
<<
endl
;
// TODO: make this more efficient
for
(
size_t
i
=
0
;
i
<
times_
.
size
();
i
++
)
{
o
<<
times_
[
i
];
for
(
auto
&
iter
:
custom_stats_
)
{
o
<<
";"
<<
iter
.
second
[
i
];
}
o
<<
endl
;
}
}
// End Scope for output file
times_
.
clear
();
for
(
auto
&
iter
:
custom_stats_
)
{
iter
.
second
.
clear
();
}
}
};
...
...
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