mirror of
https://github.com/golang/go
synced 2024-11-18 12:34:42 -07:00
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 <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
ee8ec42929
commit
aad29eba29
@ -245,7 +245,7 @@ func BenchmarkStableInt1K_Slice(b *testing.B) {
|
|||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
copy(data, unsorted)
|
copy(data, unsorted)
|
||||||
b.StartTimer()
|
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()
|
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) {
|
func BenchmarkStableInt64K(b *testing.B) {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
|
Loading…
Reference in New Issue
Block a user