32 lines
900 B
Python
32 lines
900 B
Python
import json
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
|
|
def plottable(log: list[tuple[float, int]]):
|
|
if log:
|
|
return np.array(log).transpose()
|
|
else:
|
|
return np.array([[], []])
|
|
|
|
|
|
def plot():
|
|
plt.rcParams['figure.figsize'] = [16, 9]
|
|
plt.style.use("dark_background")
|
|
plt.subplots_adjust(left=0.03, right=0.99, top=0.99, bottom=0.05)
|
|
|
|
with open('trace/latest.json') as file:
|
|
jsonified = json.load(file)
|
|
if (log := jsonified.get('DelayedResolver:sleep:concurrency')) is not None:
|
|
plt.plot(*plottable(log))
|
|
if (log := jsonified.get('ActiveBinaryTree:add:entry')) is not None:
|
|
plt.scatter(*plottable(log), c='tomato', zorder=100, s=.5)
|
|
if (log := jsonified.get('ActiveBinaryTree:add:exit')) is not None:
|
|
plt.scatter(*plottable(log), c='gold', zorder=99, s=.5)
|
|
plt.show()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
plot()
|