#!/usr/bin/env python
from collections import OrderedDict
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib.ticker import FuncFormatter
[docs]
def create_plot(df: pd.DataFrame):
del df["lib"], df["vms"], df["shared"], df["rss"]
combined_df = pd.DataFrame(columns=["time", "uss", "pss"])
for time_step in df["time"]:
rows = df.loc[df["time"] == time_step]
entry = {
"time": time_step,
"uss": rows["uss"].sum(),
"pss": rows["pss"].sum(),
}
combined_df = combined_df.append(entry, ignore_index=True)
fig, ax = plt.subplots()
ax.yaxis.set_major_formatter(FuncFormatter(lambda x, p: format_byte_count(int(x))))
combined_df.plot(x="time", ax=ax)
plt.xlabel("Time in seconds")
plt.ylabel("RAM Usage")
plt.show()
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser("PsAnalyzer")
parser.add_argument("input")
args = parser.parse_args()
df = pd.read_csv(args.input)
create_plot(df)