aboutsummaryrefslogtreecommitdiffstats
path: root/icat/bench_test.go
blob: af58006d6c605d8903ffc3861126910c29e10f1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2026 Rose Hogenson <r@roseh.moe>
//
// This file is part of imgutil.
//
// Imgutil is free software: you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// Imgutil is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// imgutil. If not, see <https://www.gnu.org/licenses/>.

package main

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

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