chesskit-app / chesskit-swift

♟️ Swift package for implementing chess logic.
MIT License
7 stars 6 forks source link

Performance and testing improvements #6

Closed pdil closed 2 months ago

pdil commented 2 months ago

Changes

Performance Improvements

The Bitboard implementation has resulted in a ~280x improvement† in computation time when simulating a full game (85 ply) played with a Board object, including initialization, at the cost of a ~40% increase in memory usage.

Results Comparison

Based on testBoardPerformance() performance test before and after Bitboard implementation. Metric Before After % Change
CPU Time (s) 5.299 0.019 🟢 99.6% ↘
CPU Cycles (kC) 13177592.595 46831.659 🟢 99.6% ↘
CPU Instructions (kI) 63112699.927 224032.835 🟢 99.6% ↘
Peak Memory (kB) 11002.291 15373.645 🔴 39.7% ↗

Xcode Output

Before After
before - ck performance after - ck performance

† Tested on M1 Pro 8-core CPU (2021 14" Macbook Pro)