Finished benchmark and plotting
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def plot(header:str, first:list[int], second:list[int], log=False):
|
||||
plt.figure(figsize=(10, 6))
|
||||
plt.plot(range(1000,25001,1000), first, label="Lista")
|
||||
plt.plot(range(1000,25001,1000), second, label="Drzewo BST")
|
||||
plt.xlabel("Rozmiar tablicy")
|
||||
plt.ylabel("Czas (ms)")
|
||||
if log:
|
||||
plt.yscale('log', base=2)
|
||||
plt.title(header)
|
||||
plt.legend()
|
||||
plt.savefig(f"./charts/{header}.png")
|
||||
|
||||
if __name__ == "__main__":
|
||||
with open('results.csv', 'r') as file:
|
||||
data = file.read()
|
||||
lines = data.split('\n')
|
||||
headers = lines[0].split(',')
|
||||
values = [line.split(',') for line in lines[1:]]
|
||||
|
||||
bstTimes = {
|
||||
"build":[],
|
||||
"search":[],
|
||||
"delete":[]
|
||||
}
|
||||
|
||||
listTimes = {
|
||||
"build":[],
|
||||
"search":[],
|
||||
"delete":[]
|
||||
}
|
||||
|
||||
for row in values:
|
||||
if row[0] == 'BST':
|
||||
bstTimes['build'].append(float(row[1]))
|
||||
bstTimes['search'].append(float(row[2]))
|
||||
bstTimes['delete'].append(float(row[3]))
|
||||
elif row[0] == 'List':
|
||||
listTimes['build'].append(float(row[1]))
|
||||
listTimes['search'].append(float(row[2]))
|
||||
listTimes['delete'].append(float(row[3]))
|
||||
|
||||
|
||||
plot("Tworzenie", listTimes['build'], bstTimes['build'])
|
||||
plot("Wyszukiwanie", listTimes['search'], bstTimes['search'], log=True)
|
||||
plot("Usuwanie", listTimes['delete'], bstTimes['delete'])
|
||||
|
||||
Reference in New Issue
Block a user