diff options
Diffstat (limited to 'sort/sort_test.go')
| -rw-r--r-- | sort/sort_test.go | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/sort/sort_test.go b/sort/sort_test.go index 024cde4..2ca6f91 100644 --- a/sort/sort_test.go +++ b/sort/sort_test.go @@ -10,7 +10,8 @@ import ( var benchResult ds.ArrayList const minLength int = 1 -const maxLength int = 100000 +const maxLength int = 1000000 +const factor int = 100 const maxSlowLength int = 100000 var arrayListCache map[string]ds.ArrayList @@ -19,32 +20,32 @@ type sortAlgorithm func(ds.ArrayList) ds.ArrayList type sortAlgorithmInt func([]int) []int func TestSelectionSort(t *testing.T) { - for i := minLength; i <= maxSlowLength; i *= 10 { + for i := minLength; i <= maxSlowLength; i *= factor { test(Selection, i, t) } } func TestInsertionSort(t *testing.T) { - for i := minLength; i <= maxSlowLength; i *= 10 { + for i := minLength; i <= maxSlowLength; i *= factor { test(Insertion, i, t) } } func TestShellSort(t *testing.T) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { test(Shell, i, t) } } func TestMergeSort(t *testing.T) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { test(Merge, i, t) } } func TestBottomUpMergeSort(t *testing.T) { t.Log("Parallel merge sort") - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { test(BottomUpMerge, i, t) } test(BottomUpMerge, maxLength*2, t) @@ -52,92 +53,92 @@ func TestBottomUpMergeSort(t *testing.T) { func TestParallelMergeSort(t *testing.T) { t.Log("Bottom-up merge sort") - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { test(ParallelMerge, i, t) } } func TestQuickSort(t *testing.T) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { test(Quick, i, t) } } func TestParallelQuickSort(t *testing.T) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { test(ParallelQuick, i, t) } } func TestQuick3WaySort(t *testing.T) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { test(Quick3Way, i, t) } } func TestShuffleSort(t *testing.T) { - for i := 10; i <= maxLength; i *= 10 { + for i := 10; i <= maxLength; i *= factor { testShuffle(Shuffle, i, t) } } func BenchmarkInsertionSort(b *testing.B) { - for i := minLength; i <= maxSlowLength; i *= 10 { + for i := minLength; i <= maxSlowLength; i *= factor { benchmark(Insertion, i, b) } } func BenchmarkSelectionSort(b *testing.B) { - for i := minLength; i <= maxSlowLength; i *= 10 { + for i := minLength; i <= maxSlowLength; i *= factor { benchmark(Selection, i, b) } } func BenchmarkShellSort(b *testing.B) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { benchmark(Shell, i, b) } } func BenchmarkMergeSort(b *testing.B) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { benchmark(Merge, i, b) } } func BenchmarkBottomUpMergeSort(b *testing.B) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { benchmark(BottomUpMerge, i, b) } } func BenchmarkParallelMergeSort(b *testing.B) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { benchmark(ParallelMerge, i, b) } } func BenchmarkQuickSort(b *testing.B) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { benchmark(Quick, i, b) } } func BenchmarkParallelQuickSort(b *testing.B) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { benchmark(ParallelQuick, i, b) } } func BenchmarkQuick3WaySort(b *testing.B) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { benchmark(Quick3Way, i, b) } } /* func BenchmarkShuffleSort(b *testing.B) { - for i := minLength; i <= maxLength; i *= 10 { + for i := minLength; i <= maxLength; i *= factor { benchmark(Shuffle, i, b) } } |
