Skip to content

Commit

Permalink
Merge pull request #10 from lanl/scripts
Browse files Browse the repository at this point in the history
Scripts - Run and BW Plot Script
  • Loading branch information
JDTruj2018 committed Jan 31, 2023
2 parents b846467 + 926ce76 commit a73537d
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Custom
*~
*__pycache__
build*/
debug*/
scripts/
utils/
compile_commands.json
.clangd/
shm_malloc/*.o
Expand Down
71 changes: 71 additions & 0 deletions scripts/plot_test_bw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

def plot_test_bw(in_file, out_file):
print(in_file, out_file)

titles = []
dfs = []

with open(in_file) as f:
df = pd.DataFrame()
next_is_header = False

for _ in range(9):
next(f)
for line in f:
if "Running tests" in line:
next_is_header = True

titles.append(line)
elif next_is_header:
next_is_header = False

line = line.split()
tmp = line[0]
line = np.repeat(line[1:], 2)
line = [line[i] + '(R)' if i % 2 == 0 else line[i] + '(W)' for i in range(len(line))]
line = np.concatenate((tmp, line), axis=None)

df = pd.DataFrame(columns=line)
elif line == '\n':
dfs.append(df)
else:
line = line.split()

line = [line[i] for i in range(0, len(line)) if (i + 1) % 3 != 0]
line = line[:len(df.columns)]
line = [float(val) for val in line]

df.loc[len(df.index)] = line

dfs.append(df)

for df, title in zip(dfs, titles):
print(title, df)

fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(16, 10))

dfr = df.filter(regex='(R)|Threads')
dfr = dfr.set_index('Threads')
dfr.plot.bar(width=0.5, ax=axes[0])
axes[0].set_title(title + "(Read)")
axes[0].set_xlabel('# Threads')
axes[0].set_ylabel("Bandwidth (GiB/s)")
axes[0].legend(ncol=3)

dfw = df.filter(regex='(W)|Threads')
dfw = dfw.set_index('Threads')
dfw.plot.bar(width=0.5, ax=axes[1])
axes[1].set_title(title + "(Write)")
axes[1].set_xlabel('# Threads')
axes[1].set_ylabel("Bandwidth (GiB/s)")
axes[1].legend(ncol=3)

plt.tight_layout()

figname = title.replace(' ', '_').strip() + '_' + out_file
plt.savefig(figname)
21 changes: 21 additions & 0 deletions scripts/run_test_bw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
import contextlib
import subprocess

def kill_process(process):
if process.poll() is None:
process.kill()

def run_test_bw(fnames):
with contextlib.ExitStack() as stack:
processes = []
for program, outfile in zip(['./build/scoria', './build/tests/test_client'], fnames):
if outfile:
with open(outfile, "w") as f:
processes.append(stack.enter_context(subprocess.Popen(program, stdout=f)))
else:
processes.append(stack.enter_context(subprocess.Popen(program)))
stack.callback(kill_process, processes[-1])

for process in processes:
process.wait()
6 changes: 6 additions & 0 deletions scripts/simple_test_bw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python
from run_test_bw import *
from plot_test_bw import *

#run_test_bw([None, 'client.log'])
plot_test_bw('client.log', 'bw.png')
Empty file added scripts/test_bw.py
Empty file.
11 changes: 5 additions & 6 deletions tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,11 @@ int main(int argc, char **argv) {

#ifdef USE_CLIENT
// send quit request
// struct request quit_req;
// quit_req.client = client_id;
// quit_req.r_type = Quit;
// quit_req.id = ++req_id;
// scoria_put_request(&client, &quit_req);
// wait_request(&client, &quit_req);
struct request quit_req;
quit_req.r_type = Quit;
quit_req.id = ++req_id;
scoria_put_request(&client, &quit_req);
wait_request(&client, &quit_req);

cleanup(&client);
#endif
Expand Down

0 comments on commit a73537d

Please sign in to comment.