aboutsummaryrefslogtreecommitdiffstats
path: root/bench_test.go
blob: 1047865f045f5b7003354a416d52cc848a38ff6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package main

import (
	"cmp"
	"math/rand/v2"
	"testing"
)

func BenchmarkQuickSelect(b *testing.B) {
	r := rand.New(rand.NewPCG(0, 0))
	testSlice := make([]int, 3840*2160)
	for i := range testSlice {
		testSlice[i] = r.Int()
	}
	myTestSlice := make([]int, len(testSlice))
	for b.Loop() {
		b.StopTimer()
		copy(myTestSlice, testSlice)
		b.StartTimer()
		quickSelect(myTestSlice, len(myTestSlice)/2, cmp.Compare)
	}
}