-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chess+search+evaluation: add benchmarks for searching, evaluation,
making a move and generating moves
- Loading branch information
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,6 @@ clean: | |
|
||
coverage: | ||
go test -cover ./internal/chess | ||
|
||
benchmark: | ||
go test ./... -bench=. -run NONE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package chess | ||
|
||
import "testing" | ||
|
||
func BenchmarkGenerateLegalMoves(b *testing.B) { | ||
position, _ := NewPosition(StartingFen) | ||
|
||
for i := 0; i < b.N; i++ { | ||
position.GenerateMoves(LegalMoveGeneration) | ||
} | ||
} | ||
|
||
func BenchmarkGenerateCaptureMoves(b *testing.B) { | ||
position, _ := NewPosition(StartingFen) | ||
|
||
for i := 0; i < b.N; i++ { | ||
position.GenerateMoves(CaptureMoveGeneration) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package evaluation | ||
|
||
import ( | ||
"rosaline/internal/chess" | ||
"testing" | ||
) | ||
|
||
func BenchmarkEvaluate(b *testing.B) { | ||
position, _ := chess.NewPosition(chess.StartingFen) | ||
evaluator := NewEvaluator() | ||
|
||
for i := 0; i < b.N; i++ { | ||
evaluator.Evaluate(position) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package search | ||
|
||
import ( | ||
"rosaline/internal/chess" | ||
"rosaline/internal/evaluation" | ||
"testing" | ||
) | ||
|
||
func BenchmarkNegamax(b *testing.B) { | ||
position, _ := chess.NewPosition(chess.StartingFen) | ||
evaluator := evaluation.NewEvaluator() | ||
searcher := NewNegamaxSearcher(evaluator) | ||
|
||
for i := 0; i < b.N; i++ { | ||
searcher.Search(position, 4) | ||
} | ||
} |