-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_classes.py
81 lines (64 loc) · 3.03 KB
/
data_classes.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
72
73
74
75
76
77
78
79
80
81
class Event:
def __init__(self, probe_point: str, timestamp: int, pid: int, tgid: int):
self.probe_point: str = probe_point
self.timestamp: int = timestamp
self.pid: int = pid
self.tgid: int = tgid
def __lt__(self, other: 'Event') -> bool:
return self.timestamp < other.timestamp
def __le__(self, other: 'Event') -> bool:
return self.timestamp <= other.timestamp
def __gt__(self, other: 'Event') -> bool:
return self.timestamp > other.timestamp
def __ge__(self, other: 'Event') -> bool:
return self.timestamp >= other.timestamp
def __getitem__(self, item):
return self[item]
class Interval:
def __init__(self, time: int, event_a: Event, event_b: Event, pid: int, tgid: int):
self.time = time
self.event_a = event_a
self.event_b = event_b
self.pid = pid
self.tgid = tgid
def __lt__(self, other: 'Interval') -> bool:
return self.time < other.time
def __le__(self, other: 'Interval') -> bool:
return self.time <= other.time
def __gt__(self, other: 'Interval') -> bool:
return self.time > other.time
def __ge__(self, other: 'Interval') -> bool:
return self.time >= other.time
def __getitem__(self, item):
return self[item]
class Experiment:
def __init__(self, executable: str, iterations: int, dir_content: str, linux_version: str, drop_boundary_events: bool, load: str, hidden_files: int, visible_files: int, description: str, label: str = "", experiment_begin: str = None, experiment_end: str = None, events: [Event] = []):
self.executable: str = executable
self.iterations: int = iterations
self.dir_content: str = dir_content
self.linux_version: str = linux_version
self.drop_boundary_events: bool = drop_boundary_events
self.load: str = load
self.hidden_files: int = hidden_files
self.visible_files: int = visible_files
self.description: str = description
self.label: str = label
self.experiment_begin: str = experiment_begin
self.experiment_end: str = experiment_end
self.events: [Event] = events
def __getitem__(self, item):
return self[item]
def experiment_from_json(input: dict) -> Experiment:
return Experiment(executable=input["executable"],
iterations=int(input["iterations"]),
dir_content=input["dir_content"],
linux_version=input["linux_version"],
drop_boundary_events=bool(input["drop_boundary_events"]),
load=input["load"],
hidden_files=input["hidden_files"],
visible_files=input["visible_files"],
description=input["description"],
label=input["label"],
experiment_begin=input["experiment_begin"],
experiment_end=input["experiment_end"],
events=[Event(**elem) for elem in input["events"]])