This project benchmarks the performance of various TypeScript ORMs:
- Prisma
- TypeORM
- MikroORM
The repository is set up as a Yarn v4 workspace with the following projects:
packages/seed-data
: Common utilities and database schema definitionspackages/benchmark-prisma
: Prisma benchmark implementationpackages/benchmark-typeorm
: TypeORM benchmark implementationpackages/benchmark-mikroorm
: MikroORM benchmark implementation
The benchmark uses a simple schema with four entities:
Author
: Authors of booksBook
: Books written by authorsBookReview
: Reviews of booksTag
: Tags that can be applied to books
Each benchmark suite tests:
-
Loading data:
- Single author with associated books and reviews
- 10 authors with associated books and reviews
- 100 authors with associated books and reviews
- 1000 authors with associated books and reviews
-
Saving data:
- Single new author with associated book and review
- 10 new authors with associated books and reviews
- 100 new authors with associated books and reviews
- 1000 new authors with associated books and reviews
# Start the database
docker compose up -d
# Run all benchmarks
yarn bench:all
# Run specific benchmark
yarn prisma:bench
yarn typeorm:bench
yarn mikroorm:bench
Test x sizes:
- bulk-create (1, 10, 100, 1000)
- Setup: Clean database, load seed data
n
into memory - Test: Insert the
n
rows
- Setup: Clean database, load seed data
- bulk-update (1, 10, 100, 1000)
- Setup: Clean database, save the seed
n
- Test: Load all
n
rows, and update each one
- Setup: Clean database, save the seed
- bulk-load (1, 10, 100, 1000)
- Setup: Clean database, save the seed
n
- Test: Load the seed data
n
tree of data
- Setup: Clean database, save the seed
- loop-load (1, 10, 100, 1000)
- Setup: Clean database, save the seed
n
- Test: Load the seed data
n
in a loop
- Setup: Clean database, save the seed
- dup-some (1, 10, 100, 1000)
- Setup: Clean database, save the seed
n
- Test: Load max(rand(1%-5%, 1)) of the data
- Setup: Clean database, save the seed