-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_throughput_latency.py
71 lines (61 loc) · 1.65 KB
/
plot_throughput_latency.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# -*- coding: utf-8 -*-
import fileinput
import json
import os
import sys
import plotly
import plotly.graph_objects as go
plotly.io.orca.config.server_url = "orca:9091"
first = True
framework = None
fig = go.Figure()
x, y, point_labels = [], [], []
for line in fileinput.input():
data = json.loads(line)
times = [
time
for epoch_stats in data["epochs"]
for time in data["epochs"][epoch_stats]["time"]
]
batch_size = data["batch_size"]
epochs = len(data["epochs"])
total_time = sum(times)
points_per_second = (epochs*60000) / total_time
latency = total_time / len(times)
accuracy = data["epochs"][max(data["epochs"])]["accuracy"]
if data["framework"] != framework:
if framework:
fig.add_trace(
go.Scatter(
x=x,
y=y,
text=point_labels,
mode="markers",
marker=dict(size=12),
name=framework,
)
)
x, y, point_labels = [], [], []
framework = data["framework"]
x.append(points_per_second)
y.append(1000 * latency)
point_labels.append(f"acc: {accuracy} | batch size: {batch_size}")
fig.add_trace(
go.Scatter(
x=x,
y=y,
text=point_labels,
mode="markers",
marker=dict(size=12),
name=framework,
)
)
fig.update_layout(
font=dict(size=18),
yaxis=dict(title="Latency (ms)"),
xaxis=dict(title="Training speed (samples/sec)"),
)
if not os.isatty(sys.stdout.fileno()):
sys.stdout.buffer.write(fig.to_image(format="pdf"))
else:
fig.show()