예제 #1
0
func BenchmarkBitonicSort(b *testing.B) {
	b.StopTimer()
	for i := 0; i < b.N; i++ {
		src := makeTempSlice(1 << 16)
		b.StartTimer()
		mtutils.BitonicSort(src)
		b.StopTimer()
	}
}
예제 #2
0
func TestBitonicSort(t *testing.T) {

	const sliceSize = 101

	src := makeTempSlice(sliceSize)
	src1 := sort.IntSlice(make([]int, len(src)))
	copy(src1, src)
	mtutils.BitonicSort(src1)
	sort.Sort(src)
	assert.Equal(t, src, src1, "BitonicSort")

	src = makeTempSlice(sliceSize)
	copy(src1, src)
	mtutils.BitonicReverse(sort.IntSlice(src1))
	sort.Sort(sort.Reverse(src))
	assert.Equal(t, src, src1, "BitonicReverse")

}