From: Brad Fitzpatrick Date: Wed, 5 Oct 2016 04:35:59 +0000 (+0000) Subject: sort: fix a slice benchmark not using the stable variant, add another X-Git-Tag: go1.8beta1~1027 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=aad29eba296df2374e5f7d334d33649d01552c01;p=gostls13.git sort: fix a slice benchmark not using the stable variant, add another Change-Id: I9783d8023d453a72c4605a308064bef98168bcb8 Reviewed-on: https://go-review.googlesource.com/30360 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot --- diff --git a/src/sort/sort_test.go b/src/sort/sort_test.go index 08a9bf6144..45713a28cc 100644 --- a/src/sort/sort_test.go +++ b/src/sort/sort_test.go @@ -245,7 +245,7 @@ func BenchmarkStableInt1K_Slice(b *testing.B) { for i := 0; i < b.N; i++ { copy(data, unsorted) b.StartTimer() - Slice(data, func(i, j int) bool { return data[i] < data[j] }) + SliceStable(data, func(i, j int) bool { return data[i] < data[j] }) b.StopTimer() } } @@ -263,6 +263,19 @@ func BenchmarkSortInt64K(b *testing.B) { } } +func BenchmarkSortInt64K_Slice(b *testing.B) { + b.StopTimer() + for i := 0; i < b.N; i++ { + data := make([]int, 1<<16) + for i := 0; i < len(data); i++ { + data[i] = i ^ 0xcccc + } + b.StartTimer() + Slice(data, func(i, j int) bool { return data[i] < data[j] }) + b.StopTimer() + } +} + func BenchmarkStableInt64K(b *testing.B) { b.StopTimer() for i := 0; i < b.N; i++ {