From 882ffc97340ea89ffedf329b0e91de9c455ff7a4 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter.cai@uwaterloo.ca>
Date: Tue, 28 Feb 2023 13:58:02 -0500
Subject: [PATCH] Use deterministic markers and colors for plotting

---
 .gitignore                     |  1 +
 analyze/config.py              | 17 +++++++++++++++++
 analyze/memcached_conn_scan.py |  6 ++++--
 analyze/memcached_qps_scan.py  |  3 ++-
 4 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 analyze/config.py

diff --git a/.gitignore b/.gitignore
index 1269488..0c7b4fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 data
+__pycache__
diff --git a/analyze/config.py b/analyze/config.py
new file mode 100644
index 0000000..aad6ca2
--- /dev/null
+++ b/analyze/config.py
@@ -0,0 +1,17 @@
+markers = {
+  "default": ".",
+  "kernel_polling": "+",
+  "manual_polling": "x",
+  "fstack": "s",
+  "caladan": "p",
+  "caladan (per-thread QPS w/ 2 threads)": "p"
+}
+
+colors = {
+  "default": "tab:blue",
+  "kernel_polling": "tab:orange",
+  "manual_polling": "tab:purple",
+  "fstack": "tab:green",
+  "caladan": "tab:red",
+  "caladan (per-thread QPS w/ 2 threads)": "tab:red"
+}
diff --git a/analyze/memcached_conn_scan.py b/analyze/memcached_conn_scan.py
index 8e30644..10bc260 100644
--- a/analyze/memcached_conn_scan.py
+++ b/analyze/memcached_conn_scan.py
@@ -1,5 +1,6 @@
 import os
 import matplotlib.pyplot as plt
+from config import markers, colors
 
 experiments = [f for f in os.listdir('../data')
     if f.startswith('memcached_conn_scan') and len(os.listdir(os.path.join('../data', f))) > 0]
@@ -65,8 +66,9 @@ def show_plot(threads, include_caladan = False):
         data[name] = (data[name][0], [qps / 2 for qps in data[name][1]], data[name][2])
 
     for k in data:
-        plt.plot(data[k][0], data[k][1], label = k)
+       plt.plot(data[k][0], data[k][1], label = k, marker = markers[k], color = colors[k])
 
+    plt.ticklabel_format(axis = 'both', style = 'sci', scilimits = (0, 4))
     plt.xlabel('Connections (per client w/ 7 * 8 clients)')
     plt.ylabel('QPS')
 
@@ -87,7 +89,7 @@ def show_plot(threads, include_caladan = False):
         plt.title('Memcached connections vs LLC misses, %d threads' % (threads,), y = 1.08)
 
     for k in data:
-        plt.plot(data[k][0], data[k][2], label = k)
+        plt.plot(data[k][0], data[k][2], label = k, marker = markers[k], color = colors[k])
 
     plt.xlabel('Connections (per client w/ 7 * 8 clients)')
     plt.ylabel('LLC misses per request')
diff --git a/analyze/memcached_qps_scan.py b/analyze/memcached_qps_scan.py
index 330ccb2..ae98f35 100644
--- a/analyze/memcached_qps_scan.py
+++ b/analyze/memcached_qps_scan.py
@@ -1,5 +1,6 @@
 import os
 import matplotlib.pyplot as plt
+from config import markers, colors
 
 experiments = [f for f in os.listdir('../data')
     if f.startswith('memcached_qps_scan') and len(os.listdir(os.path.join('../data', f))) > 0]
@@ -62,7 +63,7 @@ def show_plot(threads, include_caladan = False):
         data[name] = ([qps / 2 for qps in data[name][0]], data[name][1])
 
     for k in data:
-        plt.plot(data[k][0], data[k][1], label = k)
+        plt.plot(data[k][0], data[k][1], label = k, marker = markers[k], color = colors[k])
 
     plt.xlabel('QPS')
     plt.ylabel('Latency (99th percentile)')
-- 
GitLab