[PR #5416] feat(bench): add benchmarks for cold-start and requests/second #22894

Open
opened 2026-04-15 21:21:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5416
Author: @igoforth
Created: 10/19/2025
Status: 🔄 Open

Base: mainHead: feat/auth-benchmark


📝 Commits (8)

  • bc42fa7 feat(bench): add benchmarks for cold-start and requests/second
  • 3c5a81f chore: update lockfile
  • 26ee25c chore: rename variables to use camelCase
  • 545bffd add bench on ci pull req, refactor to inheritance pattern
  • 48c94b3 Merge branch 'canary' into feat/auth-benchmark
  • e2cc351 linting, permission fixes on bench ci
  • 543b8e1 Merge branch 'feat/auth-benchmark' of github.com:igoforth/better-auth into feat/auth-benchmark
  • c8219a0 Merge branch 'canary' into feat/auth-benchmark

📊 Changes

8 files changed (+617 additions, -1 deletions)

View changed files

📝 .github/workflows/ci.yml (+98 -1)
📝 package.json (+1 -0)
📝 packages/better-auth/package.json (+2 -0)
packages/better-auth/src/auth.bench.ts (+499 -0)
📝 packages/core/src/env/env-impl.ts (+3 -0)
📝 packages/core/src/env/index.ts (+1 -0)
📝 pnpm-lock.yaml (+9 -0)
📝 turbo.json (+4 -0)

📄 Description

This pull request adds to the better-auth package, a new file rps.bench.ts in the src/ directory, a new bench npm script, and tinybench, a new dev dependency. rps.bench.ts adds two benchmarks, a cold-start benchmark and a requests/second (rps) benchmark.

  • Added tinybench because the experimental vitest benchmarking tool (based on tinybench) doesn't support the hooks beforeAll, beforeEach, afterEach, and afterAll. These hooks were also important to make the benchmark tool easily extensible to additional endpoints. I still use the vitest bench function to initialize the tests for debugging and so the vitest bench command works.
  • Added a debug flag for the rps benchmark to make sure I was receiving valid responses from the endpoints.
  • Added types to assist in adding new endpoints and hooks.

No breaking changes or deprecations.

Sample result (AMD Ryzen 7 5800X):
image

Fixes #5415


Summary by cubic

Adds a benchmark harness for better-auth to measure cold-start time and requests/second. Includes a simple script to run the suite locally. No breaking changes.

  • New Features

    • rps.bench.ts adds cold-start and RPS benchmarks using tinybench.
    • Extensible endpoint config with setup/before/after/teardown hooks and types; includes a ready-to-run auth suite (sign up/in, sessions, user ops).
    • Debug mode to validate responses and print results locally.
  • Dependencies

    • Adds tinybench ^5.0.1.
    • New npm script: bench → vitest bench.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/5416 **Author:** [@igoforth](https://github.com/igoforth) **Created:** 10/19/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/auth-benchmark` --- ### 📝 Commits (8) - [`bc42fa7`](https://github.com/better-auth/better-auth/commit/bc42fa73c353ba1d77ef3843d9963ec717d1a7a9) feat(bench): add benchmarks for cold-start and requests/second - [`3c5a81f`](https://github.com/better-auth/better-auth/commit/3c5a81f644d9c95713d1dcf30bb102b83dd1b8a8) chore: update lockfile - [`26ee25c`](https://github.com/better-auth/better-auth/commit/26ee25c6469a685a35c9652b93b349f6f58cf540) chore: rename variables to use camelCase - [`545bffd`](https://github.com/better-auth/better-auth/commit/545bffde36ea15a5c81763783f92ef5542808687) add bench on ci pull req, refactor to inheritance pattern - [`48c94b3`](https://github.com/better-auth/better-auth/commit/48c94b3bca81303363c6260f61c1efcde230d290) Merge branch 'canary' into feat/auth-benchmark - [`e2cc351`](https://github.com/better-auth/better-auth/commit/e2cc3516d73e9fbbced031b1eaa0b4c1ae23120b) linting, permission fixes on bench ci - [`543b8e1`](https://github.com/better-auth/better-auth/commit/543b8e1b7c687679fcdaca57937bf8847315c84c) Merge branch 'feat/auth-benchmark' of github.com:igoforth/better-auth into feat/auth-benchmark - [`c8219a0`](https://github.com/better-auth/better-auth/commit/c8219a039d95f5404497969cb8f59b61fb9ab666) Merge branch 'canary' into feat/auth-benchmark ### 📊 Changes **8 files changed** (+617 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+98 -1) 📝 `package.json` (+1 -0) 📝 `packages/better-auth/package.json` (+2 -0) ➕ `packages/better-auth/src/auth.bench.ts` (+499 -0) 📝 `packages/core/src/env/env-impl.ts` (+3 -0) 📝 `packages/core/src/env/index.ts` (+1 -0) 📝 `pnpm-lock.yaml` (+9 -0) 📝 `turbo.json` (+4 -0) </details> ### 📄 Description This pull request adds to the better-auth package, a new file `rps.bench.ts` in the `src/` directory, a new `bench` npm script, and tinybench, a new dev dependency. `rps.bench.ts` adds two benchmarks, a cold-start benchmark and a requests/second (rps) benchmark. - Added tinybench because the experimental vitest benchmarking tool (based on tinybench) doesn't support the hooks beforeAll, beforeEach, afterEach, and afterAll. These hooks were also important to make the benchmark tool easily extensible to additional endpoints. I still use the vitest bench function to initialize the tests for debugging and so the `vitest bench` command works. - Added a debug flag for the rps benchmark to make sure I was receiving valid responses from the endpoints. - Added types to assist in adding new endpoints and hooks. No breaking changes or deprecations. Sample result (AMD Ryzen 7 5800X): <img width="1432" height="513" alt="image" src="https://github.com/user-attachments/assets/a590d89f-eb20-4769-a854-62a980d21b02" /> Fixes #5415 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a benchmark harness for better-auth to measure cold-start time and requests/second. Includes a simple script to run the suite locally. No breaking changes. - **New Features** - rps.bench.ts adds cold-start and RPS benchmarks using tinybench. - Extensible endpoint config with setup/before/after/teardown hooks and types; includes a ready-to-run auth suite (sign up/in, sessions, user ops). - Debug mode to validate responses and print results locally. - **Dependencies** - Adds tinybench ^5.0.1. - New npm script: bench → vitest bench. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 21:21:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#22894