Skip to content

@pokertools/bench ​

Benchmark suites for the evaluator plus load/soak scripts for the API, workers and sockets.

Usage ​

bash
npm run bench                          # full suite (requires API + Redis for API benches)
npm run bench -w @pokertools/bench -- evaluator   # evaluator benchmarks only

Benchmark output is benchmark.js-style table: ops/sec, margin of error and the slowest/fastest ratio per suite.

Prerequisites ​

SuiteNeeds API runningNeeds Redis
Evaluator❌❌
API✅✅
Workers❌✅
Socket✅✅

Start the stack with npm run dev:api + npm run dev:workers (or the Docker stack, see Deployment).

What is benchmarked ​

SuiteMeasures
Evaluator5/6/7-card evaluation throughput (hands/sec), string vs integer API
APIRequest latency/throughput against Fastify routes
WorkersBullMQ queue throughput (settle, archive, deal)
SocketWebSocket session churn and state-update fan-out

Evaluator comparison ​

The evaluator suite compares @pokertools/evaluator against popular JS libraries (phe, poker-evaluator, pokersolver):

ImplementationApprox. throughput
@pokertools/evaluator (integer API)millions of hands/sec
phefast C-style tables, lower than evaluator
poker-evaluatormoderate
pokersolverslowest (high-level string API)

TIP

Published throughput figures are illustrative of the local machine — run the suite on your own hardware for numbers you can rely on.

Writing a new benchmark ​

ts
import Benchmark from "benchmark";
import { evaluateStrings } from "@pokertools/evaluator";

const hand = ["As", "Ks", "Qs", "Js", "Ts"];

new Benchmark("evaluate royal flush", {
  fn: () => evaluateStrings(hand),
  onComplete: (event: any) => console.log(String(event.target)),
}).run();

Load & soak scripts ​

  • api/* — sustained request load against a running API instance
  • workers/* — queue saturation tests
  • socket/* — connection churn and fan-out soak

These require the API (and Redis) to be running — see the API docs.

Released under the MIT License.