Created
November 2, 2021 23:41
-
-
Save bananabrick/d3babcac2d103eaa23e340a31cf38de3 to your computer and use it in GitHub Desktop.
Parse pebble log output and plot stuff
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
import matplotlib.pyplot as plt | |
import sys | |
def read(filepath): | |
times = [] | |
fs = [] | |
commit = [] | |
throughputs = [] | |
find_insert = False | |
with open(filepath) as f: | |
for l in f: | |
l = l.strip() | |
if l.startswith("insert_100") and find_insert: | |
find_insert = False | |
times.append(l.split()[1]) | |
throughputs.append(float(l.split()[2])) | |
if l.startswith("fs"): | |
fs.append(float(l.split()[2])) | |
if l.startswith("commit"): | |
find_insert = True | |
commit.append(float(l.split()[2])) | |
return times, fs, commit, throughputs | |
def plot(filename, times, fs_lat, commit_lat, throughput): | |
SMALL_SIZE = 10 | |
x = [i * 10 for i in range(len(times))] | |
# Create figure and subplot manually | |
# fig = plt.figure() | |
# host = fig.add_subplot(111) | |
color1 = plt.cm.viridis(0) | |
color2 = plt.cm.viridis(0.5) | |
color3 = plt.cm.viridis(.9) | |
fig, host = plt.subplots(figsize=(8,5)) # (width, height) in inches | |
# (see https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.pyplot.subplots.html) | |
# time in 10s increments | |
host.set_xlim(0, 1200) | |
host.set_ylim(0, 10) | |
host.set_ylabel("fsync lat(ms)") | |
host.set_xlabel("time(s)") | |
p1, = host.plot(x, fs_lat, color=color1, label="fsync latency") | |
fig.tight_layout() | |
plt.savefig("fsync.png") | |
fig, host = plt.subplots(figsize=(8,5)) # (width, height) in inches | |
# (see https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.pyplot.subplots.html) | |
# time in 10s increments | |
host.set_xlim(0, 1200) | |
host.set_ylim(0, 30) | |
host.set_ylabel("commit lat(ms)") | |
host.set_xlabel("time(s)") | |
p1, = host.plot(x, commit_lat, color=color1, label="commit latency") | |
fig.tight_layout() | |
plt.savefig("commit.png") | |
fig, host = plt.subplots(figsize=(8,5)) # (width, height) in inches | |
# (see https://matplotlib.org/3.3.3/api/_as_gen/matplotlib.pyplot.subplots.html) | |
# time in 10s increments | |
host.set_xlim(0, 1200) | |
host.set_ylabel("throughput(ops/sec)") | |
host.set_xlabel("time(s)") | |
p1, = host.plot(x, throughput, color=color1, label="commit latency") | |
fig.tight_layout() | |
plt.savefig("throughput.png") | |
if __name__ == "__main__": | |
fpath = sys.argv[1] | |
times, fs_lat, commit_lat, throughput = read(fpath) | |
times = times[:-1] | |
fs_lat = fs_lat[:-2] | |
commit_lat = commit_lat[:-2] | |
throughput = throughput[:-1] | |
print(throughput) | |
plot("file", times, fs_lat, commit_lat, throughput) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment