Skip to content
Snippets Groups Projects
Commit 7cb7f0d6 authored by Jarrod Pas's avatar Jarrod Pas
Browse files

Adds activity to csv trace

parent 17594222
No related branches found
No related tags found
1 merge request!3Version 0.2
......@@ -11,8 +11,10 @@ class CSVTrace(Trace):
if not time == 'time' and a == 'a' and b == 'b' and state == 'state':
raise ValueError('improperly formatted csv')
# first row of data is csv is [duration, -1, -1, nodes]
duration, _, _, nodes = map(int, next(self.reader))
# first row of data is csv is [duration, activity, -1, nodes]
duration, _, _, nodes = next(self.reader)
duration = int(duration)
nodes = int(nodes)
super().__init__(duration, nodes)
def process(self, **kwargs):
......
#!/usr/bin/env python
#!/usr/bin/env python3
from collections import defaultdict
import csv
......@@ -67,12 +67,13 @@ traces.sort()
duration = traces[-1][0] + SLOT_SIZE
nodes = next(node_id)
activity = (0.5*len(traces)) / ((nodes*(nodes-1))*0.5*(duration/SLOT_SIZE))
path = sys.argv[1].split('.csv')[0] + '_reduced.csv'
with open(path, 'w') as f:
writer = csv.writer(f)
writer.writerow(['time', 'a', 'b', 'state'])
writer.writerow([duration, -1, -1, nodes])
writer.writerow([duration, f'{activity:.3E}', -1, nodes])
for trace in traces:
writer.writerow(trace)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment