From aee630b03f48a9f528a4a50e9dcb0fdc8ef20aa5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 14 Jul 2020 09:34:50 +0100 Subject: add bench helper --- sort/selection_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sort/selection_test.go') diff --git a/sort/selection_test.go b/sort/selection_test.go index 3881850..c5d6beb 100644 --- a/sort/selection_test.go +++ b/sort/selection_test.go @@ -5,8 +5,16 @@ import ( "testing" ) -func BenchmarkSelection1000(b *testing.B) { +func BenchmarkSelection(b *testing.B) { + benchmark("Selection", 10, Selection, b) + benchmark("Selection", 100, Selection, b) + benchmark("Selection", 1000, Selection, b) +} + +func TestSelection1000(t *testing.T) { a := ds.RandomIntegers(1000, 1000) - b.ResetTimer() - Selection(a) + a = Selection(a) + if !Sorted(a) { + t.Errorf("Array not sorted: %v", a) + } } -- cgit v1.2.3