-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcpu_stat_file.py
More file actions
40 lines (30 loc) · 1.12 KB
/
cpu_stat_file.py
File metadata and controls
40 lines (30 loc) · 1.12 KB
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
import pickle
VERSION_PROCESS_CPU_PERCENTAGE = "VERSION_PROCESS_CPU_PERCENTAGE"
VERSION_CPU_PERCENTAGES = "VERSION_CPU_PERCENTAGES"
VERSION_CPU_TIMES_PERCENTAGES = "VERSION_CPU_TIMES_PERCENTAGES"
def start_recording(version, output, start_time, num_cpus):
pickle.dump(version, output)
pickle.dump(start_time, output)
pickle.dump(num_cpus, output)
def write_cpu_stats(output, time_offset, cpu_stats):
pickle.dump(time_offset, output)
pickle.dump(cpu_stats, output)
def end_recording(output):
pass
def start_reading(input):
binary_version = pickle.load(input)
start_time = pickle.load(input)
num_cpus = pickle.load(input)
return binary_version, start_time, num_cpus
def start_reading_version(version, input):
binary_version = pickle.load(input)
assert binary_version == version, "binary file is not of the expected format"
start_time = pickle.load(input)
num_cpus = pickle.load(input)
return start_time, num_cpus
def read_cpu_stats(input):
time_offset = pickle.load(input)
cpu_stats = pickle.load(input)
return time_offset, cpu_stats
def end_reading(input):
pass