Sorting/sorting.py
BBaoVanC 88bb9f38f5
Add files
Date modified:
  insertion.py: 2017-09-10 13:07
  merge.py: 2017-09-10 13:54
  numgen.py: 2017-09-10 13:15
  sorting.py: 2018-08-26 16:08
2020-10-06 16:00:52 -05:00

41 lines
868 B
Python
Executable File

"""
Sorting
by BBaoVanC
Compares times between sorting systems.
"""
from timeit import default_timer as timer
import numgen
import merge
import insertion
DO_DEBUG = False
f = open("compare_sort.csv", "w+") # format: Amount,Insertion,Merge
n = 0
while n <= 1000:
A = numgen.generate(n, 8, DO_DEBUG)
print("Generated list with length: %i" % n)
start1 = timer()
sort1 = insertion.sort(A)
elapsed_time1 = timer() - start1
print("Insertion test finished")
start2 = timer()
sort2 = merge.sort(A)
elapsed_time2 = timer() - start2
print("Merge test finished")
f.write("%i,%.8f,%.8f\n" % (len(A), elapsed_time1, elapsed_time2))
# print("Amount: %i" % len(A))
# print("Insertion: %.5f" % elapsed_time1)
# print("Merge: %.5f" % elapsed_time2)
# print("--------------------------------")
n += 1
f.close()