-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from lanl/scripts
Scripts - Run and BW Plot Script
- Loading branch information
Showing
6 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters