This commit is contained in:
2026-01-06 10:13:38 -08:00
parent e26b79751f
commit 8dbfc45ebb
7 changed files with 394 additions and 291 deletions

View File

@@ -4,9 +4,9 @@ import (
"fmt"
"time"
"git.eeqj.de/sneak/pokercore"
"github.com/rcrowley/go-metrics"
"github.com/schollz/progressbar/v3"
"sneak.berlin/go/pokercore"
)
var gameCount = 50_000
@@ -101,13 +101,16 @@ func main() {
timer := metrics.NewTimer()
registry.Register("pokerGame", timer)
bar := progressbar.NewOptions(gameCount,
bar := progressbar.NewOptions(
gameCount,
progressbar.OptionSetDescription("Gambling..."),
progressbar.OptionShowCount(),
progressbar.OptionShowIts(),
progressbar.OptionSetPredictTime(true),
progressbar.OptionClearOnFinish(),
progressbar.OptionThrottle(100*time.Millisecond), // Update every 100ms
progressbar.OptionThrottle(
100*time.Millisecond,
), // Update every 100ms
)
for i := 0; i < gameCount; i++ {
@@ -128,11 +131,13 @@ func main() {
fmt.Printf("Max: %d ns\n", timer.Max())
fmt.Printf("Mean: %0.2f ns\n", timer.Mean())
fmt.Printf("StdDev: %0.2f ns\n", timer.StdDev())
fmt.Printf("Percentiles: 50%%: %0.2f ns, 75%%: %0.2f ns, 95%%: %0.2f ns, 99%%: %0.2f ns\n",
fmt.Printf(
"Percentiles: 50%%: %0.2f ns, 75%%: %0.2f ns, 95%%: %0.2f ns, 99%%: %0.2f ns\n",
timer.Percentile(0.50),
timer.Percentile(0.75),
timer.Percentile(0.95),
timer.Percentile(0.99))
timer.Percentile(0.99),
)
oneWinPercentage := float64(oneWins) / float64(gameCount) * 100
twoWinPercentage := float64(twoWins) / float64(gameCount) * 100
fmt.Printf("Player 1 won: %d (%0.2f%%)\n", oneWins, oneWinPercentage)