aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@ugent.be>2018-06-29 14:56:41 +0200
committerSander Vrijders <sander.vrijders@ugent.be>2018-06-29 14:56:41 +0200
commit936e062469367df23adbbf08a9c33725472517c1 (patch)
treeaa0315acd459194acd075c36893cf46fedb712d6
parent7c02fbc57439f5ab850b3f605df84e549174b11b (diff)
downloadrumba-936e062469367df23adbbf08a9c33725472517c1.tar.gz
rumba-936e062469367df23adbbf08a9c33725472517c1.zip
tools: Add script to subtract two bandwidth csv
This adds a script to subtract two csv with bandwidth results from each other. It can then be passed to bw_graph.py.
-rw-r--r--rumba/prototypes/ouroboros.py2
-rwxr-xr-xtools/bw_graph.py14
-rwxr-xr-xtools/subtract.py48
3 files changed, 57 insertions, 7 deletions
diff --git a/rumba/prototypes/ouroboros.py b/rumba/prototypes/ouroboros.py
index 1ca5e6d..5556d42 100644
--- a/rumba/prototypes/ouroboros.py
+++ b/rumba/prototypes/ouroboros.py
@@ -300,7 +300,7 @@ class Experiment(mod.Experiment):
def _terminate_prototype(self, force=False):
cmds = list()
- if force:
+ if force is True:
kill = 'killall -9 '
cmds.append(kill + 'irmd')
cmds.append(kill + 'ipcpd-normal')
diff --git a/tools/bw_graph.py b/tools/bw_graph.py
index ab772d4..d283713 100755
--- a/tools/bw_graph.py
+++ b/tools/bw_graph.py
@@ -26,6 +26,9 @@ def get_color(value, max):
else:
val = math.floor(multiplier - 1)
+ if value < 0:
+ val = math.floor(multiplier - 1)
+
color = color_range[val]
return color.get_hex()
@@ -34,7 +37,7 @@ def get_penwidth(value, max):
if max == 0:
return "1.0"
- r = (4.0 * float(value) / (0.5 * max)) + 1
+ r = (4.0 * float(abs(value)) / (0.5 * max)) + 1
return str(r)
description = "CSV to bandwidth graph script"
@@ -63,10 +66,8 @@ bandwidth = {}
nodes = set()
for row in reader:
nodes.add(row[0])
- if (row[1], row[0]) in bandwidth:
- bandwidth[row[1], row[0]] += int(row[2])
- else:
- bandwidth[row[0], row[1]] = int(row[2])
+ nodes.add(row[1])
+ bandwidth[row[0], row[1]] = int(row[2])
node_bandwidth = {}
for key, value in bandwidth.items():
@@ -103,7 +104,8 @@ for key, value in bandwidth.items():
pw = get_penwidth(value, max_b)
edge = pydot.Edge(key[0], key[1],
color = color,
- penwidth=pw)
+ penwidth=pw,
+ label=round(value * 8 / 1000000, 2))
gvizg.add_edge(edge)
except Exception as e:
print('Failed to create pydot Edge: ' + str(e))
diff --git a/tools/subtract.py b/tools/subtract.py
new file mode 100755
index 0000000..6929b61
--- /dev/null
+++ b/tools/subtract.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+import argparse
+import csv
+import math
+
+description = "Subtracts two CSV from each other"
+epilog = "2018 Sander Vrijders <sander.vrijders@ugent.be>"
+
+parser = argparse.ArgumentParser(description=description,
+ epilog=epilog)
+
+parser.add_argument('-o', '--output', type=str, required=True,
+ help='Output CSV filename.')
+
+parser.add_argument('-f', '--first', type=str, required=True,
+ help='First input CSV filename.')
+
+parser.add_argument('-s', '--second', type=str, required=True,
+ help='Second input CSV filename.')
+
+args = parser.parse_args()
+
+csvfile = open(args.second, 'r')
+reader = csv.reader(csvfile, delimiter=';', quotechar='|')
+
+# Set second measurement
+bandwidth = {}
+for row in reader:
+ if (row[1], row[0]) in bandwidth:
+ bandwidth[row[1], row[0]] += int(row[2])
+ else:
+ bandwidth[row[0], row[1]] = int(row[2])
+
+# Subtract first measurement
+csvfile2 = open(args.first, 'r')
+reader2 = csv.reader(csvfile2, delimiter=';', quotechar='|')
+for row in reader2:
+ if (row[1], row[0]) in bandwidth:
+ bandwidth[row[1], row[0]] -= int(row[2])
+ else:
+ bandwidth[row[0], row[1]] -= int(row[2])
+
+
+csvfile3 = open(args.output, 'w')
+writer = csv.writer(csvfile3, delimiter=';', quotechar='|')
+for key, value in bandwidth.items():
+ writer.writerow([key[0], key[1], value])