From c0f1b213a3ef38ccde6f052da8ca2ea9b3120e17 Mon Sep 17 00:00:00 2001 From: Jeremy Hertel Date: Sat, 25 Nov 2023 21:54:01 -0600 Subject: [PATCH] evaluation: add more cases to evaluator benchmarks --- internal/evaluation/evaluator_test.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/internal/evaluation/evaluator_test.go b/internal/evaluation/evaluator_test.go index 6bd5104..837a92d 100644 --- a/internal/evaluation/evaluator_test.go +++ b/internal/evaluation/evaluator_test.go @@ -5,11 +5,25 @@ import ( "testing" ) -func BenchmarkEvaluate(b *testing.B) { - position, _ := chess.NewPosition(chess.StartingFen) +func evaluateBenchmark(b *testing.B, fen string) { + position, _ := chess.NewPosition(fen) evaluator := NewEvaluator() for i := 0; i < b.N; i++ { evaluator.Evaluate(position) } } + +func BenchmarkEvaluate(b *testing.B) { + cases := []string{ + chess.StartingFen, + "7R/5pkp/4pN2/4P1P1/6K1/6P1/q1r5/7r w - - 1 46", + "Bn2kbnr/p1p1pppp/3q4/8/3P4/2N3Pb/PPP2P1P/R1BQR1K1 b k - 0 13", + } + + for _, c := range cases { + b.Run(c, func(b *testing.B) { + evaluateBenchmark(b, c) + }) + } +}