-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use LruHashMap over HashMap for pending messages
- Loading branch information
Thomas Braun
committed
Jul 12, 2023
1 parent
ca02f61
commit 982f2fe
Showing
2 changed files
with
51 additions
and
6 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
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,43 @@ | ||
import psutil | ||
import sys | ||
import matplotlib.pyplot as plt | ||
from matplotlib import animation | ||
from collections import deque | ||
import numpy as np | ||
|
||
if len(sys.argv) < 2: | ||
print("Error: PID not specified") | ||
sys.exit(1) | ||
|
||
pid = int(sys.argv[1]) | ||
|
||
try: | ||
process = psutil.Process(pid) | ||
except psutil.NoSuchProcess: | ||
print(f"No process found with PID: {pid}") | ||
sys.exit(1) | ||
|
||
fig = plt.figure() | ||
ax = fig.add_subplot(1, 1, 1) | ||
xs = deque(maxlen=10000) | ||
ys = deque(maxlen=10000) | ||
|
||
|
||
def animate(i): | ||
mem = process.memory_info().rss / (1024**2) | ||
|
||
xs.append(i) | ||
ys.append(mem) | ||
|
||
ax.clear() | ||
ax.plot(xs, ys) | ||
|
||
if len(xs) > 1: | ||
m, b = np.polyfit(xs, ys, 1) | ||
print(f"Slope: {m}") | ||
reg_line = [m*x + b for x in xs] | ||
ax.plot(xs, reg_line, color='red') | ||
|
||
|
||
ani = animation.FuncAnimation(fig, animate, interval=1000) | ||
plt.show() |