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/insertion_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sort/insertion_test.go') diff --git a/sort/insertion_test.go b/sort/insertion_test.go index 4b503b8..afec414 100644 --- a/sort/insertion_test.go +++ b/sort/insertion_test.go @@ -5,8 +5,16 @@ import ( "testing" ) -func BenchmarkInsertion1000(b *testing.B) { +func BenchmarkInsertion(b *testing.B) { + benchmark("Insertion", 10, Insertion, b) + benchmark("Insertion", 100, Insertion, b) + benchmark("Insertion", 1000, Insertion, b) +} + +func TestInsertion1000(t *testing.T) { a := ds.RandomIntegers(1000, 1000) - b.ResetTimer() - Insertion(a) + a = Insertion(a) + if !Sorted(a) { + t.Errorf("Array not sorted: %v", a) + } } -- cgit v1.2.3