-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiozone.py
67 lines (52 loc) · 1.93 KB
/
iozone.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
import matplotlib.pyplot as plt
import pandas as pd
import re
from pathlib import Path
import numpy as np
from plot import *
# Function to parse Iozone output
def parse_iozone_output(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
# Find the header line and the data section
header_line = None
data_lines = []
for line in lines:
if "reclen" in line and header_line is None:
header_line = line
elif re.match(r"^\s*\d+", line):
data_lines.append(line.strip())
# Parse header and data
if not header_line or not data_lines:
raise ValueError("Invalid Iozone output format")
headers = header_line.split()
data = []
for line in data_lines:
data.append([float(val) for val in line.split()])
return pd.DataFrame(data, columns=headers)
def process_values(df):
df.columns.values[6] = "random read"
df.columns.values[7] = "random write"
df.columns.values[8] = "bkwd read"
df.columns.values[9] = "record rewrite"
df.columns.values[10] = "stride read"
# Useless columns
df = df.drop(['kB', 'reclen'], axis=1)
# Calculate the mean for each column
return df.mean()
if __name__ == "__main__":
values = []
names = []
folder_path = Path("results")
for file_path in folder_path.rglob('*'): # Recursively search all files
if is_workload(file_path, "iozone"):
file_path = str(file_path)
df = parse_iozone_output(file_path)
names.append(file_path.split('/')[1].split('.')[0].split('_')[1])
values.append(process_values(df))
indices = np.array(values[0].index)
values = list(map(lambda x: x.values, values))
print(names)
print(values)
title = 'IOzone microbenchmark - throuput in [KB/s] (averaged by r/w size from 64kb to 512mb)'
generate_plot(values, names, indices, title, "iozone")