Commit e3f8205e by FritzFlorian

Add memory measures to benchmarks.

parent 8f47876d
Pipeline #1503 passed with stages
in 4 minutes 26 seconds
......@@ -38,6 +38,7 @@ int main(int argc, char **argv) {
string test_name = to_string(num_threads) + ".csv";
string full_directory = directory + "/PLS_v3/";
benchmark_runner runner{full_directory, test_name};
runner.enable_memory_stats();
fft::complex_vector data(fft::SIZE);
fft::complex_vector swap_array(fft::SIZE);
......
......@@ -36,6 +36,7 @@ int main(int argc, char **argv) {
string test_name = to_string(num_threads) + ".csv";
string full_directory = directory + "/PLS_v3/";
benchmark_runner runner{full_directory, test_name};
runner.enable_memory_stats();
pls::scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE};
......
......@@ -31,6 +31,7 @@ int main(int argc, char **argv) {
string test_name = to_string(num_threads) + ".csv";
string full_directory = directory + "/PLS_v3/";
benchmark_runner runner{full_directory, test_name};
runner.enable_memory_stats();
pls_matrix<double, matrix::MATRIX_SIZE> a;
pls_matrix<double, matrix::MATRIX_SIZE> b;
......
......@@ -112,6 +112,7 @@ int main(int argc, char **argv) {
string test_name = to_string(num_threads) + ".csv";
string full_directory = directory + "/PLS_v3/";
benchmark_runner runner{full_directory, test_name};
runner.enable_memory_stats();
// Only run on one version to avoid copy
std::unique_ptr<double[]> result_data{new double[size * size]};
......
......@@ -42,6 +42,7 @@ int main(int argc, char **argv) {
string test_name = to_string(num_threads) + ".csv";
string full_directory = directory + "/PLS_v3/";
benchmark_runner runner{full_directory, test_name};
runner.enable_memory_stats();
scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE};
......
......@@ -29,6 +29,12 @@ class benchmark_runner {
chrono::steady_clock::time_point last_start_time_;
vector<long> times_;
bool memory_stats_enabled_{false};
const string MEMORY_PRE_RUN = "memory_pages_pre_run";
const string MEMORY_POST_RUN = "memory_pages_post_run";
unsigned long memory_pre_run_;
unsigned long memory_post_run_;
map<string, vector<long>> custom_stats_;
void print_statistics() {
......@@ -96,6 +102,12 @@ class benchmark_runner {
custom_stats_.insert({name, {}});
}
void enable_memory_stats() {
memory_stats_enabled_ = true;
add_custom_stats_field(MEMORY_PRE_RUN);
add_custom_stats_field(MEMORY_POST_RUN);
}
static void read_args(int argc, char **argv, int &num_threads, string &path) {
if (argc < 3) {
cout << "Must Specifiy concurrency and output directory! (usage: `benchmark <output_directory> <num_threads>`)"
......@@ -109,17 +121,31 @@ class benchmark_runner {
}
void start_iteration() {
if (memory_stats_enabled_) {
auto memory_stats = query_process_memory_pages();
memory_pre_run_ = memory_stats.first;
}
last_start_time_ = chrono::steady_clock::now();
}
void end_iteration() {
size_t iteration_index = times_.size();
auto end_time = chrono::steady_clock::now();
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);
}
if (memory_stats_enabled_) {
auto memory_stats = query_process_memory_pages();
memory_post_run_ = memory_stats.first;
custom_stats_[MEMORY_PRE_RUN][iteration_index] = memory_pre_run_;
custom_stats_[MEMORY_POST_RUN][iteration_index] = memory_post_run_;
}
}
void store_custom_stat(const string &name, long value) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment