Skip to content

Commit

Permalink
chess: add benchmarks for generating zobrist hash
Browse files Browse the repository at this point in the history
  • Loading branch information
e0ff committed Nov 26, 2023
1 parent a9810ad commit a3d54f0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/chess/zobrist_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package chess

import "testing"

func generateHashBenchmark(b *testing.B, fen string) {
position, _ := NewPosition(fen)
for i := 0; i < b.N; i++ {
generateHash(position)
}
}

func BenchmarkGenerateHash(b *testing.B) {
cases := []string{
StartingFen,
"1b2k2r/Pppp1ppp/5nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w k - 0 1",
}

for _, c := range cases {
b.Run(c, func(b *testing.B) {
generateHashBenchmark(b, c)
})
}
}

0 comments on commit a3d54f0

Please sign in to comment.