Benchmarks

Every package of Deepkit has benchmarks. The comparisons with other libraries use the same data and run in the same process, on a dedicated machine.

What is measured here: TypeScript ORM, TypeScript RPC framework, TypeScript dependency injection, TypeScript validation, TypeScript backend framework.

master ebfe04cb32026-11-10Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHzNode.js v26.13.0

Validation and serialization

Operations per second, higher is better. Deepkit reads the TypeScript types at runtime, so there is no schema to write: the validators check a plain interface User. typia also uses TypeScript types, but generates its code at build time. Benchmark source code on GitHub

Validation of valid data

Checks a user object with nested profile and an array of roles. The result is true or false.

typia (AOT) 15.2.0
41.5M ops/s
ArkType 2.2.9
27.4M ops/s
TypeBox 0.34.52
26.1M ops/s
Deepkit guard()
24.8M ops/s
Deepkit is()
19.9M ops/s
Zod 4.6.7
3.9M ops/s
Valibot 1.5.0
679K ops/s

Validation errors

The same object with an invalid nested field. The result contains the errors with their path.

Deepkit validate()
5.6M ops/s
typia (AOT) 15.2.0
1.0M ops/s
Zod 4.6.7
708K ops/s
Valibot 1.5.0
528K ops/s
TypeBox 0.34.52
119K ops/s
ArkType 2.2.9
50.5K ops/s

Deserialization

JSON-compatible data to a typed object: dates, nested objects, arrays.

Deepkit deserialize()
6.6M ops/s
Deepkit cast() with validation
3.7M ops/s
class-transformer 0.5.1
84.0K ops/s

Serialization to JSON

A typed object to a JSON string.

JSON.stringify (no types)
1.5M ops/s
Deepkit + JSON.stringify
1.3M ops/s
typia json.stringify 15.2.0
1.0M ops/s

Databases

Complete ORM operations against a real database on the same machine: a table with 10,000 rows, read as entities or objects of each library. Time per operation, the longer the bar the faster. The raw drivers (striped) are the lower bound of what an ORM on top of them can reach. Benchmark source code on GitHub

PostgreSQL

findOne by id

A row by its primary key.

Deepkit
84 µs
postgres.js (driver) 3.4.9
117 µs
pg (driver) 8.23.1
118 µs
Sequelize 6.37.8
417 µs
Drizzle 0.45.4
436 µs
TypeORM 1.1.2
455 µs
Prisma 7.10.1
526 µs
MikroORM 7.2.5
600 µs

Load 10,000 rows

All rows of the table as objects.

Deepkit
6.5 ms
postgres.js (driver) 3.4.9
14 ms
pg (driver) 8.23.1
18 ms
Drizzle 0.45.4
18 ms
Prisma 7.10.1
23 ms
TypeORM 1.1.2
24 ms
Sequelize 6.37.8
41 ms
MikroORM 7.2.5
120 ms

Insert 1,000 rows

All rows in one call, nothing returned.

Deepkit
25 ms
pg (driver) 8.23.1
26 ms
postgres.js (driver) 3.4.9
31 ms
MikroORM 7.2.5
34 ms
TypeORM 1.1.2
37 ms
Sequelize 6.37.8
42 ms
Drizzle 0.45.4
62 ms
Prisma 7.10.1
95 ms

Insert 1,000 entities

Through the ORM, generated primary keys are returned.

Deepkit
31 ms
TypeORM 1.1.2
39 ms
Sequelize 6.37.8
41 ms
MikroORM 7.2.5
49 ms
Drizzle 0.45.4
63 ms
Prisma 7.10.1
94 ms

Under load, with 128 users in 4 processes and a pool of 10 connections per process: Deepkit answers 94,395 findOne queries per second, 4.4× as many as TypeORM, 4.9× Drizzle, 5.4× Sequelize, 6.2× Prisma, 7.5× MikroORM, 1.7× the postgres.js driver and 1.8× the pg driver. Loading 100 rows per query, it reaches 31,107 per second, 3.5× as many as Drizzle, 3.7× TypeORM, 4.0× Prisma, 5.3× Sequelize, 12× MikroORM, 1.9× the pg driver and 2.1× the postgres.js driver. That makes Deepkit ORM the fastest PostgreSQL ORM for TypeScript by a wide margin: ahead of every other ORM in every benchmark, and when reading even faster than the raw pg and postgres.js drivers.

SQLite

findOne by id

A row by its primary key.

better-sqlite3 (driver) 12.11.1
4.8 µs
Deepkit
11 µs
TypeORM 1.1.2
98 µs
Drizzle 0.45.4
98 µs
Prisma 7.10.1
182 µs
MikroORM 7.2.5
288 µs
Sequelize 6.37.8
458 µs

Load 10,000 rows

All rows of the table as objects.

Deepkit
5.2 ms
better-sqlite3 (driver) 12.11.1
6.4 ms
Drizzle 0.45.4
11 ms
TypeORM 1.1.2
17 ms
Prisma 7.10.1
19 ms
Sequelize 6.37.8
80 ms
MikroORM 7.2.5
107 ms

Insert 1,000 rows

All rows in one call, nothing returned.

Deepkit
1.8 ms
better-sqlite3 (driver) 12.11.1
3.2 ms
MikroORM 7.2.5
5.0 ms
TypeORM 1.1.2
8.6 ms
Sequelize 6.37.8
8.8 ms
Drizzle 0.45.4
16 ms
Prisma 7.10.1
62 ms

Insert 1,000 entities

Through the ORM, generated primary keys are returned.

Deepkit
2.5 ms
Sequelize 6.37.8
8.7 ms
TypeORM 1.1.2
9.9 ms
MikroORM 7.2.5
16 ms
Drizzle 0.45.4
16 ms
Prisma 7.10.1
63 ms

That makes Deepkit ORM the fastest SQLite ORM for TypeScript by a wide margin: ahead of every other ORM in every benchmark.

MongoDB

findOne by id

A row by its primary key.

Deepkit
191 µs
mongodb (driver) 7.7.0
438 µs
Mongoose 9.11.4
516 µs
MikroORM 7.2.5
635 µs

Load 10,000 rows

All rows of the table as objects.

Deepkit
7.5 ms
mongodb (driver) 7.7.0
32 ms
Mongoose 9.11.4
76 ms
MikroORM 7.2.5
139 ms

Insert 1,000 rows

All rows in one call, nothing returned.

Deepkit
4.1 ms
mongodb (driver) 7.7.0
6.1 ms
MikroORM 7.2.5
9.6 ms
Mongoose 9.11.4
27 ms

Insert 1,000 entities

Through the ORM, generated primary keys are returned.

Deepkit
5.5 ms
MikroORM 7.2.5
23 ms
Mongoose 9.11.4
26 ms

Under load, with 128 users in 4 processes and a pool of 10 connections per process: Deepkit answers 51,148 findOne queries per second, 3.3× as many as Mongoose, 4.7× MikroORM and 2.7× the mongodb driver. Loading 100 rows per query, it reaches 19,633 per second, 5.3× as many as Mongoose, 8.6× MikroORM and 3.3× the mongodb driver. That makes Deepkit ORM the fastest MongoDB ORM for TypeScript by a wide margin: ahead of every other ORM in every benchmark, and even faster than the raw mongodb driver.

RPC

Complete calls over a local socket, with client and server in one process. Time per call, the longer the bar the faster. The libraries do different amounts of work: Deepkit validates the arguments from their types and uses binary BSON over TCP or WebSocket (TCP in these measurements), tRPC validates with Zod and uses JSON over HTTP, gRPC uses Protocol Buffers over HTTP/2 and only checks the message structure, and Socket.IO sends JSON without validation. Plain ws (striped) sends JSON with no framework at all, as a reference point. Benchmark source code on GitHub

Small call

Two numbers as arguments, one number as result.

Deepkit (TCP)
33 µs
Deepkit (WebSocket)
65 µs
ws (no framework) 8.22.1
67 µs
Socket.IO 4.8.4
115 µs
gRPC 1.14.7
543 µs
tRPC 11.22.1
905 µs

Object call

A user object as argument and as result.

Deepkit (TCP)
42 µs
ws (no framework) 8.22.1
60 µs
Deepkit (WebSocket)
64 µs
Socket.IO 4.8.4
116 µs
gRPC 1.14.7
589 µs
tRPC 11.22.1
1.1 ms

List of 100 objects

One number as argument, 100 user objects as result.

Deepkit (TCP)
178 µs
Deepkit (WebSocket)
195 µs
ws (no framework) 8.22.1
217 µs
Socket.IO 4.8.4
280 µs
gRPC 1.14.7
962 µs
tRPC 11.22.1
1.0 ms

Under load, with 64 connections and 8 calls in flight on each: Deepkit answers 485,246 small calls per second over TCP, 8.9× as many as Socket.IO, 36× gRPC, 111× tRPC and 7.9× plain ws without a framework. With an object as argument and result, it answers 209,342 calls per second over TCP, 4.2× as many as Socket.IO, 16× gRPC, 56× tRPC and 3.5× plain ws without a framework. Over WebSocket, the transport of Socket.IO and ws, it still answers 94,499 small calls per second, 1.7× as many as Socket.IO and 1.5× plain ws without a framework. Deepkit RPC is the fastest RPC framework for TypeScript by a wide margin, ahead of gRPC, tRPC and Socket.IO in every benchmark, and even faster than plain WebSocket messages without any framework.

RPC between threads and processes

Deepkit RPC from the main thread to a server in a worker thread or child process, over the IPC channels and, for comparison, a unix socket and TCP. Shared memory and MessagePort go to a worker thread, the others to a child process. Client and server run in parallel on two cores. Time per call, the longer the bar the faster. Shared memory polls for the answer for 100 µs before it sleeps, without polling every call waits for the operating system to wake up the other thread. Benchmark source code on GitHub

Small call

Two numbers as arguments, one number as result.

Shared memory
5.7 µs
Pipe
33 µs
Unix socket
33 µs
Shared memory, no polling
38 µs
MessagePort
40 µs
TCP
55 µs
process.send
60 µs

Object call

A user object as argument and as result.

Shared memory
9.9 µs
Pipe
39 µs
Shared memory, no polling
43 µs
Unix socket
44 µs
MessagePort
47 µs
TCP
50 µs
process.send
66 µs

List of 100 objects

One number as argument, 100 user objects as result.

Shared memory
138 µs
Shared memory, no polling
171 µs
Pipe
173 µs
Unix socket
199 µs
MessagePort
201 µs
TCP
209 µs
process.send
247 µs

64 calls at once

64 small calls in flight, one operation is all of them.

Shared memory
68 µs
Unix socket
85 µs
Pipe
88 µs
TCP
95 µs
MessagePort
95 µs
Shared memory, no polling
97 µs
process.send
113 µs

A small call to a worker thread over shared memory takes 5.7 µs, 5.9x faster than over a unix socket (33.3 µs) and 9.7x faster than over TCP (55.3 µs).

Broker

Key-value and pub/sub with 64 connections and 8 in-flight calls per connection, spread over 5 client processes. Operations per second over all clients, higher is better. Each server runs in its own process, in-memory and with its default threading: the Deepkit broker is one Node.js process, Redis and Valkey are native servers. The Redis, Valkey and NATS clients exchange JSON, Deepkit binary encoded from the types. NATS only has the pub/sub workload, since its key-value store needs JetStream, which persists. Benchmark source code on GitHub

Read an object

A user object by its key.

Deepkit Broker
316K ops/s
Redis (node-redis) 6.3.1
312K ops/s
Redis (ioredis) 5.6.1
273K ops/s
Valkey (ioredis) 5.6.1
263K ops/s

Write an object

A user object under a key.

Redis (node-redis) 6.3.1
328K ops/s
Deepkit Broker
289K ops/s
Redis (ioredis) 5.6.1
281K ops/s
Valkey (ioredis) 5.6.1
256K ops/s

Increment

A counter under a key.

Deepkit Broker
364K ops/s
Redis (ioredis) 5.6.1
308K ops/s
Valkey (ioredis) 5.6.1
303K ops/s
Redis (node-redis) 6.3.1
299K ops/s

Publish and receive

A user object, until the subscriber received it.

NATS 3.4.0
279K ops/s
Deepkit Broker
253K ops/s
Redis (ioredis) 5.6.1
248K ops/s
Valkey (ioredis) 5.6.1
226K ops/s
Redis (node-redis) 6.3.1
195K ops/s

Releases and master

Time per operation in the last releases and in master, the same benchmarks on the same machine, each with its change to the column before. Compared with 1.1.0, master is faster in 69, slower in 2 and unchanged within the measurement error in 303 of 374 benchmarks.

1.0.191.1.0master
Validation and serialization
is<User>() 411 ns 54 ns 7.7× faster 50 ns +6.3%
validate<User>() with errors 618 ns 184 ns 3.4× faster 179 ns +2.8%
serialize<User>() 642 ns 174 ns 3.7× faster 128 ns 1.4× faster
deserialize<User>() 690 ns 189 ns 3.6× faster 151 ns 1.3× faster
cast<User>() 1.2 µs 393 ns 3.1× faster 267 ns 1.5× faster
deserialize<T[]>(), 100 items 143 µs 9.1 µs 15.7× faster 7.3 µs 1.2× faster
Runtime types
typeOf<Order>() 216 ns 21 ns 10.2× faster 21 ns -0.5%
resolveReceiveType<User>() 650 ns 299 ns 2.2× faster 301 ns -0.7%
ReflectionClass.from(), cached 74 ns 72 ns +2.1% 73 ns -0.9%
Change detection
Detect changes, medium entity 542 ns 542 ns -0.0% 545 ns -0.7%
Create snapshot, medium entity 3.6 µs 3.7 µs -2.6% 3.6 µs +3.2%
BSON
Serialize small object 405 ns 400 ns +1.3% 430 ns -7.2%
Deserialize small object 456 ns 449 ns +1.5% 240 ns 1.9× faster
RPC
RPC action call 9.4 µs 9.5 µs -1.0% 984 ns 9.7× faster
HTTP
GET with route parameter 117 µs 117 µs +0.0% 120 µs -2.2%
POST with validated JSON body 221 µs 226 µs -2.1% 233 µs -3.0%
Route with query string 2.7 µs 1.1 µs 2.4× faster 1.1 µs +1.2%
HTTP body with 10 users 111 µs 4.4 µs 25.5× faster 4.6 µs -4.4%
Serialize API response 192 µs 18 µs 10.5× faster 18 µs +0.8%
Dependency injection, app and events
injector.get() 22 ns 22 ns +0.0% 22 ns -0.0%
injector.get() with dependencies 22 ns 22 ns -0.2% 22 ns -0.0%
Scoped service, new scope 54 ns 54 ns +0.5% 54 ns -1.1%
App with 5 module imports 13 µs 13 µs +3.9% 12 µs +6.1%
Event with one listener 17 ns 17 ns +1.3% 18 ns -3.6%
ORM and database
SQLite findOne 64 µs 64 µs +0.1% 12 µs 5.2× faster
Hydrate 100 entities 137 µs 78 µs 1.7× faster 79 µs -0.5%
MongoDB insert of 100 entities 1.9 ms 2.0 ms -4.2% 1.4 ms 1.4× faster
MongoDB deleteMany of 1,000 documents – – 6.9 ms

Bundle size and build time

What runtime types cost at build time, measured on our own sources pinned to one commit: the same tsc run (type check and emit) without and with the type compiler. Changes are since the last release (1.1.0).

CodebaseJS plainJS + typesSize overheadGzip overheadChangeBuild plainBuild + typesBuild overheadChange
example-app8 files · 375 lines13.2 KB17.9 KB+35.5%+38.8%+1.0 points1.94 s2.07 s+6.6%+0.1%
http16 files · 4,054 lines126.5 KB175.1 KB+38.5%+48.3%+0.1 points2.01 s2.66 s+32.2%-4.5%
framework29 files · 3,815 lines139.5 KB181.6 KB+30.2%+38.4%+1.8 points2.68 s3.40 s+26.5%-2.2%
type27 files · 12,997 lines469.6 KB578.2 KB+23.1%+30.7%+0.5 points3.42 s4.15 s+21.5%+0.9%

Size overhead of runtime types

Build time with runtime types

Build time overhead of runtime types

Over time

Time per operation, lower is better, of whole features from the oldest measured release to master. White circles are releases. The factor compares master with the last release (1.1.0), grey if within the measurement error. Hover a point for its numbers.

Database

HTTP requests

RPC

Dependency injection and app

Validation and serialization

All benchmarks

Time per operation in master and the change of operations per second since the last release. Changes within twice the measurement error are shown in grey.

App modules15 benchmarks · packages/app/benchmarks/app.bench.ts
createModule - empty29 µs34.6K ops/s -1.5%
createModule - with providers28 µs35.3K ops/s -1.1%
module class instantiation1.9 µs521K ops/s +3.2%
module class with config1.8 µs543K ops/s +6.6%
App creation - empty1.5 µs671K ops/s -1.7%
App creation - with providers2.0 µs507K ops/s +5.6%
App creation - with imports3.8 µs266K ops/s +3.1%
App.get() - resolve service137 ns7.3M ops/s -7.2%
App.get() - from imported module47 ns21.5M ops/s -0.0%
App.configure()2.6 µs387K ops/s +1.8%
App creation - nested imports5.5 µs182K ops/s +1.4%
App.setup() chain1.9 µs522K ops/s +0.3%
Module.configure()2.6 µs387K ops/s +2.9%
AppModule direct instantiation1.5 µs682K ops/s +0.8%
App creation - 5 module imports12 µs83.3K ops/s +6.1%
BSON16 benchmarks · packages/bson/benchmarks/bson.bench.ts
serialize small object430 ns2.3M ops/s -7.2%
deserialize small object240 ns4.2M ops/s 1.9× faster
serialize object with dates559 ns1.8M ops/s 1.2× slower
deserialize object with dates603 ns1.7M ops/s 1.4× faster
serialize nested object822 ns1.2M ops/s 1.1× faster
deserialize nested object691 ns1.4M ops/s 1.5× faster
serialize array (1000 items)557 µs1.8K ops/s 1.3× faster
deserialize array (1000 items)483 µs2.1K ops/s 1.7× faster
serialize array (5000 items)2.8 ms359 ops/s 1.3× faster
deserialize array (5000 items)2.5 ms407 ops/s 1.9× faster
serialize number array (1000)45 µs22.0K ops/s 1.4× faster
deserialize number array (1000)27 µs37.6K ops/s -1.5%
serialize string array (1000)126 µs7.9K ops/s 4.2× faster
deserialize string array (1000)221 µs4.5K ops/s 1.2× faster
serialize complex document2.0 µs489K ops/s 1.5× faster
deserialize complex document2.8 µs359K ops/s 1.4× faster
Events9 benchmarks · packages/event/benchmarks/event.bench.ts
sync event - single listener18 ns56.2M ops/s -3.6%
sync event - no listeners18 ns54.5M ops/s -2.3%
async event - single sync listener346 ns2.9M ops/s +1.8%
async event - single async listener371 ns2.7M ops/s +1.4%
async event - 10 listeners1.2 µs852K ops/s -0.8%
data event - with payload448 ns2.2M ops/s +3.5%
sync event - pre-compiled dispatcher20 ns49.1M ops/s -0.2%
sync event - with propagation stop81 ns12.4M ops/s -1.0%
dispatcher creation + listener add430 ns2.3M ops/s -2.2%
HTTP router and serialization28 benchmarks · packages/http/benchmarks/http.bench.ts
route match - simple static147 ns6.8M ops/s +2.3%
route match - single param210 ns4.8M ops/s +0.1%
route match - multi param273 ns3.7M ops/s +1.7%
route match - with query1.1 µs886K ops/s +0.7%
route match - many routes (first)66 ns15.1M ops/s +1.8%
route match - many routes (middle)132 ns7.6M ops/s -2.8%
route match - many routes (last)379 ns2.6M ops/s -6.4%
route match - not found213 ns4.7M ops/s -1.7%
resolve request - simple45 ns22.2M ops/s +1.6%
resolve request - with params192 ns5.2M ops/s 1.3× faster
resolve request - with query1.1 µs892K ops/s +1.2%
serialize - single user1.6 µs615K ops/s -0.8%
serialize - user array (10)16 µs62.2K ops/s +0.5%
serialize - api response18 µs55.3K ops/s +0.8%
JSON.stringify - single user2.9 µs340K ops/s +0.1%
JSON.stringify - user array (10)23 µs44.0K ops/s -0.0%
deserialize - single user458 ns2.2M ops/s -0.0%
deserialize - user array (10)4.6 µs219K ops/s -4.4%
JSON.parse - single user800 ns1.2M ops/s -0.0%
create router registry11 ns91.8M ops/s 1.2× faster
registry - add GET route306 ns3.3M ops/s +1.2%
registry - add 5 routes1.3 µs782K ops/s +0.9%
resolveUrl - single param5.6 ns179M ops/s -2.1%
resolveUrl - multi param9.1 ns110M ops/s -0.9%
middleware config - create7.5 µs134K ops/s -0.3%
middleware config - with route filter15 µs68.2K ops/s +1.2%
read controller metadata38 ns26.1M ops/s 1.1× faster
get routes from router0.8 ns1296M ops/s -4.5%
HTTP requests5 benchmarks · packages/http/benchmarks/kernel.bench.ts
GET with route parameter120 µs8.3K ops/s -2.2%
GET list of 10 with query parameter159 µs6.3K ops/s -2.0%
POST with validated JSON body233 µs4.3K ops/s -3.0%
validation error (400)116 µs8.6K ops/s -3.6%
not found (404)84 µs11.9K ops/s -5.0%
Dependency injection10 benchmarks · packages/injector/benchmarks/injector.bench.ts
baseline: new Database()0.7 ns1348M ops/s +0.3%
get simple provider22 ns46.4M ops/s -0.0%
get provider with dependencies22 ns46.2M ops/s -0.0%
get via resolver function0.7 ns1362M ops/s +0.0%
scoped: same scope (cached)39 ns25.7M ops/s +1.7%
scoped: new scope each call54 ns18.5M ops/s -1.1%
context.getInjector().get()24 ns41.4M ops/s -3.2%
new InjectorContext(module)2.1 ns467M ops/s -0.0%
createChildScope()2.2 ns460M ops/s -3.4%
createChildScope().getInjector()14 ns69.8M ops/s -0.5%
Dependency injection: scaling26 benchmarks · packages/injector/benchmarks/scaling.bench.ts
10 providers: get()9.7 ns104M ops/s +0.0%
10 providers: resolver()0.8 ns1297M ops/s -3.6%
50 providers: get()9.7 ns103M ops/s -0.5%
50 providers: resolver()0.7 ns1334M ops/s -0.3%
100 providers: get()9.7 ns104M ops/s +0.0%
100 providers: resolver()0.7 ns1338M ops/s 1.3× faster
200 providers: get()9.7 ns104M ops/s -0.0%
200 providers: resolver()0.7 ns1338M ops/s +0.2%
500 providers: get()9.7 ns104M ops/s +0.1%
500 providers: resolver()0.7 ns1339M ops/s +0.6%
chain depth 1: get()9.7 ns104M ops/s +0.1%
chain depth 3: get()9.7 ns104M ops/s +0.1%
chain depth 5: get()9.7 ns104M ops/s +0.1%
chain depth 10: get()9.7 ns103M ops/s -0.4%
singleton: get()22 ns46.4M ops/s +0.1%
scoped: same scope get()43 ns23.4M ops/s -0.6%
scoped: new scope + get()139 ns7.2M ops/s +1.7%
tag injection: get service with tags9.7 ns104M ops/s +0.1%
transient: get() (new instance)55 ns18.2M ops/s +2.3%
non-transient: get() (cached)22 ns46.2M ops/s +0.7%
resolver caching: direct get()9.7 ns104M ops/s +0.1%
resolver caching: cached resolver()0.7 ns1347M ops/s -1.0%
resolver caching: context.resolve()0.7 ns1345M ops/s -1.1%
injector creation: 10 providers146 µs6.9K ops/s +1.2%
injector creation: 100 providers7.7 ms131 ops/s +0.2%
injector creation: 500 providers83 ms12.0 ops/s +0.6%
Logger14 benchmarks · packages/logger/benchmarks/logger.bench.ts
log info - no formatter229 ns4.4M ops/s 1.1× faster
log info - default formatter2.7 µs373K ops/s +0.9%
log info - color formatter1.4 µs721K ops/s +2.3%
log debug level248 ns4.0M ops/s +0.5%
log warning level249 ns4.0M ops/s +0.4%
log error level250 ns4.0M ops/s +0.1%
log info - disabled (filtered)22 ns45.8M ops/s +0.4%
scoped logger - info1.4 µs700K ops/s +1.5%
scoped logger creation (cached)0.7 ns1361M ops/s +2.0%
log with format args685 ns1.5M ops/s +4.8%
log with data359 ns2.8M ops/s +2.4%
memory logger - info582 ns1.7M ops/s +0.2%
log info - 3 transports657 ns1.5M ops/s 1.4× slower
logger.is() check5.2 ns193M ops/s -0.4%
ORM with MongoDB10 benchmarks · packages/mongo/benchmarks/mongo.bench.ts
convert filter (no database)1.6 µs624K ops/s +3.2%
findOne by _id230 µs4.4K ops/s 1.4× faster
find 100 with hydration882 µs1.1K ops/s 1.4× faster
find 100 without hydration (lean)859 µs1.2K ops/s 1.4× faster
count with filter799 µs1.3K ops/s 35.7× faster
insert one199 µs5.0K ops/s 1.5× faster
insert 100 in one session1.4 ms699 ops/s 1.4× faster
patchOne360 µs2.8K ops/s +7.8%
change detection + update of a loaded entity759 µs1.3K ops/s 1.1× faster
deleteMany 1,000 rows6.9 ms145 ops/s new
RPC actions20 benchmarks · packages/rpc/benchmarks/actions.bench.ts
simple: ping (no args, string return)1.0 µs973K ops/s 10.1× faster
simple: echo (string arg, string return)1.1 µs917K ops/s 9.0× faster
simple: add (2 number args, number return)984 ns1.0M ops/s 9.7× faster
simple: validateNumber (with validation)1.0 µs983K ops/s 9.9× faster
user: getUser (entity return)2.0 µs497K ops/s 7.7× faster
user: createUser (2 string args, entity return)2.2 µs455K ops/s 7.7× faster
product: getProduct (entity return)2.0 µs502K ops/s 10.3× faster
product: createProduct (complex args, entity return)3.3 µs302K ops/s 5.9× faster
user: listUsers (complex result with array)10.0 µs100K ops/s 3.9× faster
product: search (object args, array return)11 µs88.6K ops/s 4.1× faster
user: processUsers (2 items)2.7 µs365K ops/s 6.5× faster
user: processUsers (10 items)8.2 µs122K ops/s 4.5× faster
user: processUsers (100 items)70 µs14.3K ops/s 3.2× faster
product: bulkCreate (2 items)3.2 µs314K ops/s 6.9× faster
product: bulkCreate (10 items)10 µs96.5K ops/s 4.2× faster
type cache: first call (cold)642 µs1.6K ops/s 1.5× slower
type cache: subsequent calls (warm)1.1 µs924K ops/s 8.8× faster
sequential: 5 simple calls4.5 µs220K ops/s 10.3× faster
sequential: 5 entity calls9.7 µs104K ops/s 8.2× faster
connect + call + disconnect584 µs1.7K ops/s 1.3× slower
RPC messages0 benchmarks · packages/rpc/benchmarks/messages.bench.ts
ORM with SQLite18 benchmarks · packages/sqlite/benchmarks/orm.bench.ts
deserialize single entity771 ns1.3M ops/s +2.5%
deserialize 100 entities79 µs12.7K ops/s -0.5%
cast single entity1.2 µs846K ops/s +1.6%
serialize single entity2.0 µs501K ops/s +1.4%
create query359 ns2.8M ops/s 2.8× faster
query with filter448 ns2.2M ops/s 4.9× faster
query with multiple filters1.0 µs980K ops/s 6.0× faster
query with select672 ns1.5M ops/s 3.6× faster
clone query109 ns9.1M ops/s 10.8× faster
create session98 ns10.2M ops/s 1.7× faster
session add item780 ns1.3M ops/s -3.9%
session add 10 items3.8 µs261K ops/s 1.4× faster
query count4.0 µs251K ops/s 4.2× faster
query findOne12 µs81.3K ops/s 5.2× faster
query find (limit 10)40 µs24.7K ops/s 2.2× faster
query find with filter41 µs24.2K ops/s 2.5× faster
insert single item52 µs19.4K ops/s 1.3× faster
patch single item218 µs4.6K ops/s +7.8%
Change detection21 benchmarks · packages/type/benchmarks/change-detection.bench.ts
createSnapshot (small entity)8.4 ns119M ops/s -0.0%
createSnapshot (medium entity)3.6 µs277K ops/s +3.2%
createSnapshot (large entity)5.9 µs168K ops/s +6.3%
detect changes (no changes, small)36 ns28.1M ops/s -0.5%
detect changes (no changes, medium)317 ns3.2M ops/s -0.5%
detect changes (no changes, large)933 ns1.1M ops/s +5.5%
detect changes (with changes, small)175 ns5.7M ops/s +0.1%
detect changes (with changes, medium)545 ns1.8M ops/s -0.7%
detect changes (with changes, large)1.6 µs641K ops/s -0.7%
extract primary key (small)1.6 ns632M ops/s -0.1%
extract primary key (medium)1.7 ns594M ops/s -1.0%
extract primary key (large)28 ns36.0M ops/s -2.3%
generate PK hash (small)5.0 ns199M ops/s +0.5%
generate PK hash (medium)5.1 ns197M ops/s -0.0%
generate PK hash (large)28 ns35.8M ops/s -1.8%
buildChanges (no changes, small)207 ns4.8M ops/s +1.3%
buildChanges (no changes, medium)4.2 µs238K ops/s +2.5%
buildChanges (no changes, large)7.7 µs130K ops/s +4.2%
buildChanges (with changes, small)280 ns3.6M ops/s 1.1× faster
buildChanges (with changes, medium)4.4 µs227K ops/s +2.7%
buildChanges (with changes, large)8.3 µs121K ops/s +4.9%
Runtime types37 benchmarks · packages/type/benchmarks/reflection.bench.ts
ReflectionClass.from (cached)73 ns13.7M ops/s -0.9%
typeOf<string>788 ns1.3M ops/s +1.0%
typeOf<number>820 ns1.2M ops/s -0.2%
typeOf<User>290 ns3.5M ops/s -0.8%
typeOf<Product>21 ns47.3M ops/s 2.7× slower
typeOf<Order>21 ns47.2M ops/s -0.5%
typeOf<PaymentMethod>21 ns47.2M ops/s -4.9%
typeOf<User[]>2.1 µs467K ops/s -4.4%
typeOf<Map<string, User>>2.4 µs417K ops/s +4.7%
reflect(User)189 ns5.3M ops/s -2.1%
reflect(function)184 ns5.4M ops/s +0.6%
resolveReceiveType<string>8.8 ns113M ops/s 1.7× faster
resolveReceiveType<User>301 ns3.3M ops/s -0.7%
getProperties()0.7 ns1356M ops/s +0.0%
getPropertyNames()0.7 ns1357M ops/s +0.1%
getProperty(name)20 ns49.5M ops/s +1.4%
hasProperty(name)25 ns39.3M ops/s -0.9%
iterate all properties43 ns23.0M ops/s -0.0%
getMethods()0.7 ns1357M ops/s -0.0%
getMethodNames()0.7 ns1357M ops/s -0.0%
getMethod(name)16 ns62.6M ops/s -0.0%
hasMethod(name)21 ns47.1M ops/s +0.7%
method.getParameters()24 ns41.8M ops/s -0.0%
type.kind === ReflectionKind.string3.4 ns297M ops/s -0.0%
type.kind === ReflectionKind.class3.4 ns297M ops/s -0.0%
type.kind === ReflectionKind.union3.4 ns297M ops/s -0.0%
type.kind === ReflectionKind.array3.4 ns297M ops/s -0.0%
property.isOptional()0.7 ns1357M ops/s +0.0%
property.getType()0.7 ns1357M ops/s +0.1%
property.isArray()3.4 ns297M ops/s +0.0%
property.getKind()0.9 ns1056M ops/s +0.0%
ReflectionFunction.from(fn)290 ns3.4M ops/s +0.2%
function.getParameters()0.7 ns1351M ops/s -0.0%
function.getReturnType()0.7 ns1357M ops/s +0.0%
reflection.getClassName()4.2 ns238M ops/s -0.0%
reflection.getClassType()3.8 ns264M ops/s +0.0%
reflection.getConstructorOrUndefined()9.6 ns104M ops/s +0.0%
Serialization24 benchmarks · packages/type/benchmarks/serialization.bench.ts
deepkit small deserialize467 ns2.1M ops/s 1.1× faster
deepkit small serialize477 ns2.1M ops/s 1.1× faster
deepkit medium deserialize863 ns1.2M ops/s 1.3× faster
deepkit medium serialize2.4 µs418K ops/s 1.1× faster
deepkit large deserialize5.1 µs197K ops/s +6.3%
deepkit large serialize13 µs79.9K ops/s +9.8%
deepkit array[100] deserialize7.3 µs138K ops/s 1.2× faster
deepkit array[100] serialize7.4 µs135K ops/s 1.3× faster
deepkit array[1000] deserialize75 µs13.4K ops/s 1.3× faster
deepkit array[1000] serialize77 µs13.0K ops/s 1.3× faster
deepkit array[10000] deserialize1.7 ms593 ops/s 1.2× faster
deepkit array[10000] serialize810 µs1.2K ops/s 1.4× faster
deepkit deeply-nested deserialize940 ns1.1M ops/s 1.1× faster
deepkit deeply-nested serialize2.1 µs478K ops/s +6.0%
deepkit union-types deserialize930 ns1.1M ops/s 1.3× faster
deepkit union-types serialize1.1 µs952K ops/s 1.3× faster
deepkit special-types deserialize4.0 µs250K ops/s -0.4%
deepkit special-types serialize9.0 µs111K ops/s +1.5%
deepkit tree-structure deserialize1.2 µs861K ops/s 1.1× faster
deepkit tree-structure serialize1.1 µs889K ops/s 1.2× faster
deepkit linked-list deserialize675 ns1.5M ops/s +7.2%
deepkit linked-list serialize646 ns1.5M ops/s +5.9%
deepkit category-hierarchy deserialize1.2 µs852K ops/s 1.1× faster
deepkit category-hierarchy serialize1.2 µs865K ops/s +7.7%
Unions3 benchmarks · packages/type/benchmarks/union.bench.ts
guard union (rotating members)51 ns19.5M ops/s -0.4%
guard union text only44 ns22.6M ops/s +0.4%
deserialize union288 ns3.5M ops/s -0.9%
Validation33 benchmarks · packages/type/benchmarks/validation.bench.ts
guard (valid)35 ns28.4M ops/s -0.8%
guard (invalid)41 ns24.4M ops/s +0.2%
validate (valid)37 ns26.9M ops/s +3.0%
validate (invalid)140 ns7.1M ops/s -0.1%
is (valid, no errors)61 ns16.5M ops/s +3.6%
is (invalid, no errors)72 ns13.8M ops/s -0.3%
is (valid, with errors)70 ns14.3M ops/s +0.5%
is (invalid, with errors)158 ns6.3M ops/s -3.6%
assert (valid)83 ns12.1M ops/s +1.9%
assert (invalid, try-catch)6.8 µs146K ops/s +1.3%
constraints (valid)241 ns4.2M ops/s -0.8%
constraints (invalid)395 ns2.5M ops/s -0.4%
constraints validate (invalid)821 ns1.2M ops/s +0.0%
array objects (valid)121 ns8.3M ops/s -0.7%
array objects (invalid)328 ns3.0M ops/s +1.5%
array objects validate (invalid)1.6 µs622K ops/s -0.5%
large array (100 items)3.2 µs309K ops/s +0.3%
deep nested (valid)717 ns1.4M ops/s +1.3%
deep nested (invalid)932 ns1.1M ops/s +0.2%
deep nested validate (invalid)2.9 µs348K ops/s 1.2× faster
union text (valid)25 ns39.5M ops/s 1.2× faster
union image (valid)31 ns32.0M ops/s -1.1%
union video (valid)30 ns33.4M ops/s -0.9%
union file (valid)32 ns30.9M ops/s -1.0%
union text (invalid)116 ns8.6M ops/s +0.1%
union image (invalid)125 ns8.0M ops/s +0.3%
union validate (invalid)644 ns1.6M ops/s -0.1%
overhead: guard (valid)37 ns27.4M ops/s -2.0%
overhead: validate (valid)41 ns24.2M ops/s +0.7%
overhead: guard (invalid)45 ns22.3M ops/s -1.5%
overhead: validate (invalid)124 ns8.1M ops/s +0.8%
overhead: guard (many errors)362 ns2.8M ops/s -0.1%
overhead: validate (many errors)870 ns1.1M ops/s +0.0%

Run them yourself

The benchmarks are in benchmarks/ of each package and in benchmarks/comparison. The results are written to benchmarks/results/<machine>; the ones of this page are committed in the repository.

git clone https://github.com/deepkit/deepkit-framework.git
cd deepkit-framework
yarn && npm run postinstall && npm run tsc

npm run bench                         # all benchmarks
npm run bench -- type bson            # files whose path contains type or bson
npm run bench -- --target 1.0.19      # the same benchmarks against a published version
Made in Germany