summaryrefslogtreecommitdiff
path: root/sort/sort_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2020-07-26 08:48:45 +0100
committerPaul Buetow <paul@buetow.org>2020-07-26 08:48:45 +0100
commitd330522b31f9a32e9549745008b596fdca9b17e5 (patch)
tree610a283416d66ca81c9d83ab3026c7fb770e616d /sort/sort_test.go
parentde286db8594d547591ff765f4d5934d99248779b (diff)
also have bottom-up merge sort
Diffstat (limited to 'sort/sort_test.go')
-rw-r--r--sort/sort_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/sort/sort_test.go b/sort/sort_test.go
index 59e0226..8415d7d 100644
--- a/sort/sort_test.go
+++ b/sort/sort_test.go
@@ -37,6 +37,23 @@ func TestMergeSort(t *testing.T) {
for i := 1; i <= maxLength; i *= 10 {
test(Merge, i, t)
}
+ test(Merge, maxLength*2, t)
+}
+
+func TestMerge2Sort(t *testing.T) {
+ t.Log("Parallel merge sort")
+ for i := 1; i <= maxLength; i *= 10 {
+ test(Merge2, i, t)
+ }
+ test(Merge2, maxLength*2, t)
+}
+
+func TestMerge3Sort(t *testing.T) {
+ t.Log("Bottom-up merge sort")
+ for i := 1; i <= maxLength; i *= 10 {
+ test(Merge3, i, t)
+ }
+ test(Merge3, maxLength*2, t)
}
func TestShuffleSort(t *testing.T) {
@@ -69,6 +86,18 @@ func BenchmarkMergeSort(b *testing.B) {
}
}
+func BenchmarkMerge2Sort(b *testing.B) {
+ for i := 1; i <= maxLength; i *= 10 {
+ benchmark(Merge2, i, b)
+ }
+}
+
+func BenchmarkMerge3Sort(b *testing.B) {
+ for i := 1; i <= maxLength; i *= 10 {
+ benchmark(Merge3, i, b)
+ }
+}
+
func BenchmarkShuffleSort(b *testing.B) {
for i := 1; i <= maxLength; i *= 10 {
benchmark(Shuffle, i, b)