Refactor benchmark to use randomized vectors instead of sets
- Replaced std::set with std::vector for sequence handling. - Added randomization of sequences to avoid ordered input bias. - Removed unused balance function and related code in bst.cpp and bst.h. - Fixed bugs in list insertion and search logic. - Updated plot.py to allow custom y-axis labels and enable log scale for build plots.
This commit is contained in:
+4
-4
@@ -1,11 +1,11 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def plot(header:str, first:list[int], second:list[int], log=False, labels=("Lista", "Drzewo BST")):
|
||||
def plot(header:str, first:list[int], second:list[int], log=False, labels=("Lista", "Drzewo BST"), ylabel= "Czas (ms)"):
|
||||
plt.figure(figsize=(10, 6))
|
||||
plt.plot(range(1000,25001,1000), first, label=labels[0])
|
||||
plt.plot(range(1000,25001,1000), second, label=labels[1])
|
||||
plt.xlabel("Rozmiar tablicy")
|
||||
plt.ylabel("Czas (ms)")
|
||||
plt.ylabel(ylabel)
|
||||
if log:
|
||||
plt.yscale('log', base=2)
|
||||
plt.title(header)
|
||||
@@ -42,7 +42,7 @@ if __name__ == "__main__":
|
||||
listTimes['delete'].append(float(row[3]))
|
||||
|
||||
|
||||
plot("Tworzenie", listTimes['build'], bstTimes['build'])
|
||||
plot("Tworzenie", listTimes['build'], bstTimes['build'], log=True)
|
||||
plot("Wyszukiwanie", listTimes['search'], bstTimes['search'], log=True)
|
||||
plot("Usuwanie", listTimes['delete'], bstTimes['delete'])
|
||||
|
||||
@@ -55,4 +55,4 @@ if __name__ == "__main__":
|
||||
bstHeights = [int(x[0]) for x in values]
|
||||
avlHeights = [int(x[1]) for x in values]
|
||||
|
||||
plot("AVl", bstHeights, avlHeights, log=True, labels=("Drzewo BST", "Drzewo AVL"))
|
||||
plot("AVL", bstHeights, avlHeights, log=True, labels=("Drzewo BST", "Drzewo AVL"), ylabel="Wysokość drzewa")
|
||||
|
||||
Reference in New Issue
Block a user