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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
8 deletions
+86
-8
extern/benchmark_runner/benchmark_runner.h
+86
-8
No files found.
extern/benchmark_runner/benchmark_runner.h
View file @
616964f6
...
@@ -10,6 +10,14 @@
...
@@ -10,6 +10,14 @@
#include <iostream>
#include <iostream>
#include <fstream>
#include <fstream>
#include <bits/stdc++.h>
#include <bits/stdc++.h>
#include <thread>
#include <map>
#include <tuple>
#include <unistd.h>
#include <string>
#include <fstream>
#include <sstream>
using
namespace
std
;
using
namespace
std
;
...
@@ -21,9 +29,16 @@ class benchmark_runner {
...
@@ -21,9 +29,16 @@ class benchmark_runner {
chrono
::
steady_clock
::
time_point
last_start_time_
;
chrono
::
steady_clock
::
time_point
last_start_time_
;
vector
<
long
>
times_
;
vector
<
long
>
times_
;
map
<
string
,
vector
<
long
>>
custom_stats_
;
void
print_statistics
()
{
void
print_statistics
()
{
long
time_sum
=
std
::
accumulate
(
times_
.
begin
(),
times_
.
end
(),
0l
);
long
time_sum
=
std
::
accumulate
(
times_
.
begin
(),
times_
.
end
(),
0l
);
cout
<<
"Average Runtime (us): "
<<
(
time_sum
/
times_
.
size
())
<<
endl
;
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
)
{
inline
bool
file_exists
(
const
std
::
string
&
name
)
{
...
@@ -32,17 +47,53 @@ class benchmark_runner {
...
@@ -32,17 +47,53 @@ class benchmark_runner {
}
}
public
:
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
)},
csv_name_
{
std
::
move
(
csv_name
)},
times_
{}
{
times_
{}
{
string
command
=
"mkdir -p "
+
csv_path_
;
string
command
=
"mkdir -p "
+
csv_path_
;
int
res
=
system
(
command
.
c_str
());
int
res
=
system
(
command
.
c_str
());
if
(
res
)
{
if
(
res
)
{
cout
<<
"Error while creating directory!"
<<
endl
;
cout
<<
"Error while creating directory!"
<<
endl
;
exit
(
1
);
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
;
}
}
return
std
::
make_pair
(
total_private
,
total_shared
);
}
times_
.
reserve
(
num_measurements
);
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
)
{
static
void
read_args
(
int
argc
,
char
**
argv
,
int
&
num_threads
,
string
&
path
)
{
...
@@ -65,22 +116,35 @@ class benchmark_runner {
...
@@ -65,22 +116,35 @@ class benchmark_runner {
auto
end_time
=
chrono
::
steady_clock
::
now
();
auto
end_time
=
chrono
::
steady_clock
::
now
();
long
time
=
chrono
::
duration_cast
<
chrono
::
microseconds
>
(
end_time
-
last_start_time_
).
count
();
long
time
=
chrono
::
duration_cast
<
chrono
::
microseconds
>
(
end_time
-
last_start_time_
).
count
();
times_
.
emplace_back
(
time
);
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
,
void
run_iterations
(
int
count
,
const
function
<
void
(
void
)
>
measure
,
const
function
<
void
(
void
)
>
measure
,
int
warmup_count
,
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
++
)
{
for
(
int
i
=
0
;
i
<
warmup_count
;
i
++
)
{
prepare
();
prepare
();
measure
();
measure
();
}
}
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
using
namespace
std
::
literals
;
this_thread
::
sleep_for
(
100u
s
);
prepare
();
prepare
();
start_iteration
();
start_iteration
();
measure
();
measure
();
end_iteration
();
end_iteration
();
finish
();
}
}
}
}
...
@@ -94,15 +158,29 @@ class benchmark_runner {
...
@@ -94,15 +158,29 @@ class benchmark_runner {
{
// Scope for output file
{
// Scope for output file
ofstream
o
(
full_filename
,
std
::
fstream
::
out
|
std
::
fstream
::
app
);
ofstream
o
(
full_filename
,
std
::
fstream
::
out
|
std
::
fstream
::
app
);
if
(
write_header
)
{
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
}
// End Scope for output file
times_
.
clear
();
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