def test_random_input(self):
     arr = [random.randint(-100000, 100000) for i in range(10000)]
     res = radix_sort(arr)
     self.assertTrue(self.check_sorted(res))
 def test_single_negative(self):
     arr = [-1]
     res = radix_sort(arr)
     expected = [-1]
     self.assertFalse(not res)
     self.assertEqual(expected, res)
 def test_multiple_negative(self):
     arr = [random.randint(-100000, -1) for i in range(1000)]
     res = radix_sort(arr)
     self.assertTrue(self.check_sorted(res))
 def test_different_length_ints(self):
     arr = [random.randint(0, 100000) for i in range(1000)]
     res = radix_sort(arr)
     self.assertTrue(self.check_sorted(res))
 def test_long_array(self):
     arr = [random.randint(0, 100000) for i in range(20000)]
     res = radix_sort(arr)
     self.assertTrue(self.check_sorted(res))
 def test_equal_length_ints(self):
     arr = [random.randint(1000, 9999) for i in range(1000)]
     res = radix_sort(arr)
     self.assertTrue(self.check_sorted(res))
 def test_trivial_3(self):
     arr = [0]
     res = radix_sort(arr)
     expected = [0]
     self.assertFalse(not res)
     self.assertEqual(expected, res)
 def test_trivial_2(self):
     arr = [123456789]
     res = radix_sort(arr)
     expected = [123456789]
     self.assertFalse(not res)
     self.assertEqual(expected, res)
 def test_empty(self):
     arr = []
     res = radix_sort(arr)
     expected = []
     self.assertEqual(expected, res)
Beispiel #10
0
# test the performance of sequential sorting vs concurrent sorting
l = list(range(1,10000000))
shuffle(l)
l_cp = deepcopy(l)
# quick_sort([1],0,0)
start_time = time.time()
quick_sort_wrapper_4(l)
print("quicksort parellel: --- %s seconds ---" % (time.time() - start_time))
l = deepcopy(l_cp)
start_time = time.time()
quick_sort_wrapper_2(l)
print("quicksort sequential: --- %s seconds ---" % (time.time() - start_time))
from radixsort import radix_sort
l = deepcopy(l_cp)
start_time = time.time()
l=radix_sort(l)
print("Radix sort: --- %s seconds ---" % (time.time() - start_time))
from countingsort import countingsort
l = deepcopy(l_cp)
start_time = time.time()
l=countingsort(l)
print("Counting sort: --- %s seconds ---" % (time.time() - start_time))
from mergesort import mergesort_wrapper_2
l = deepcopy(l_cp)
start_time = time.time()
l=mergesort_wrapper_2(l)
print("mergesort sort parellel: --- %s seconds ---" % (time.time() - start_time))



# print(l)