Skip to content

Instantly share code, notes, and snippets.

@llandsmeer
Created December 2, 2022 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llandsmeer/4f99faa18a01e48902dfab223af2783c to your computer and use it in GitHub Desktop.
Save llandsmeer/4f99faa18a01e48902dfab223af2783c to your computer and use it in GitHub Desktop.
iotf single benchmark plotter
import collections
import pandas as pd
import matplotlib.pyplot as plt
logfile = '<path to benchmark output.dat>'
tables = collections.defaultdict(list)
def tryfloat(x):
# the argument can be a float or
# an entire ndarray
# for runtimes, we only want the float
try:
return float(x)
except ValueError:
return None
for i, line in enumerate(open(logfile)):
parts = line.split(None, 6)
if parts[0] == 'row':
tables[parts[4]].append(dict(
n=int(parts[2]), # problem size
gj=int(parts[3]), # gap junction count (=10*n)
dur=float(parts[5]), # measured duration (in seconds)
arg=tryfloat(parts[6].rstrip()) # 'argument' usually the run number from 0 to 4
))
for k, rows in tables.items():
tables[k] = pd.DataFrame(rows)
print('Read table', k)
print(tables[k].head())
globals()[k] = tables[k]
def plot_runtimes(df, label):
df = df[df.arg > 0.5] # skip first run with JIT timings
df = df.groupby('n')['dur'].min() # n is problem size, take smallest runtime
n = df.index
t = df.values
print(n)
print(t)
plt.plot(n, t, label=label)
plot_runtimes(run_unconnected_perf, label='Unconnected')
plot_runtimes(run_connected_perf, label='Connected')
plt.xscale('log')
plt.yscale('log')
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment