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 c0435dc122026-11-15Intel(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.3M ops/s
ArkType 2.2.9
27.6M ops/s
TypeBox 0.34.52
25.2M ops/s
Deepkit guard()
23.9M ops/s
Deepkit is()
19.2M ops/s
Zod 4.6.7
3.9M ops/s
Valibot 1.5.0
677K ops/s

Validation errors

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

Deepkit validate()
5.3M ops/s
typia (AOT) 15.2.0
988K ops/s
Zod 4.6.7
655K ops/s
Valibot 1.5.0
530K ops/s
TypeBox 0.34.52
118K ops/s
ArkType 2.2.9
51.1K ops/s

Deserialization

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

Deepkit deserialize()
6.9M ops/s
Deepkit cast() with validation
3.7M ops/s
class-transformer 0.5.1
85.9K 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
86 µs
postgres.js (driver) 3.4.9
112 µs
pg (driver) 8.23.1
121 µs
Drizzle 0.45.4
432 µs
Sequelize 6.37.8
441 µs
TypeORM 1.1.2
449 µs
Prisma 7.10.1
525 µs
MikroORM 7.2.5
614 µs

Load 10,000 rows

All rows of the table as objects.

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

Insert 1,000 rows

All rows in one call, nothing returned.

Deepkit
26 ms
pg (driver) 8.23.1
27 ms
postgres.js (driver) 3.4.9
30 ms
MikroORM 7.2.5
33 ms
TypeORM 1.1.2
36 ms
Sequelize 6.37.8
44 ms
Drizzle 0.45.4
65 ms
Prisma 7.10.1
93 ms

Insert 1,000 entities

Through the ORM, generated primary keys are returned.

Deepkit
33 ms
TypeORM 1.1.2
39 ms
Sequelize 6.37.8
44 ms
MikroORM 7.2.5
51 ms
Drizzle 0.45.4
61 ms
Prisma 7.10.1
95 ms

Under load, with 128 users in 4 processes and a pool of 10 connections per process: Deepkit answers 100,424 findOne queries per second, 4.8× as many as TypeORM, 5.2× Drizzle, 5.9× Sequelize, 6.7× Prisma, 8.0× MikroORM, 1.8× the postgres.js driver and 2.0× the pg driver. Loading 100 rows per query, it reaches 30,959 per second, 3.4× as many as Drizzle, 3.7× TypeORM, 3.8× Prisma, 5.2× 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: 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
5.1 µs
Deepkit
11 µs
Drizzle 0.45.4
96 µs
TypeORM 1.1.2
99 µs
Prisma 7.10.1
192 µs
MikroORM 7.2.5
278 µs
Sequelize 6.37.8
520 µ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
79 ms
MikroORM 7.2.5
108 ms

Insert 1,000 rows

All rows in one call, nothing returned.

Deepkit
1.8 ms
better-sqlite3 (driver) 12.11.1
1.9 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.9 ms
TypeORM 1.1.2
9.9 ms
MikroORM 7.2.5
16 ms
Drizzle 0.45.4
16 ms
Prisma 7.10.1
64 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
181 µs
mongodb (driver) 7.7.0
424 µs
Mongoose 9.11.4
492 µs
MikroORM 7.2.5
624 µs

Load 10,000 rows

All rows of the table as objects.

Deepkit
7.3 ms
mongodb (driver) 7.7.0
31 ms
Mongoose 9.11.4
75 ms
MikroORM 7.2.5
145 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.7 ms
Mongoose 9.11.4
26 ms

Insert 1,000 entities

Through the ORM, generated primary keys are returned.

Deepkit
5.7 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,688 findOne queries per second, 3.3× as many as Mongoose, 4.8× MikroORM and 2.7× the mongodb driver. Loading 100 rows per query, it reaches 19,919 per second, 5.6× as many as Mongoose, 8.7× MikroORM and 3.5× 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)
32 µs
Deepkit (WebSocket)
64 µs
ws (no framework) 8.22.1
69 µs
Socket.IO 4.8.4
117 µs
gRPC 1.14.7
558 µs
tRPC 11.22.1
906 µs

Object call

A user object as argument and as result.

Deepkit (TCP)
40 µs
ws (no framework) 8.22.1
59 µs
Deepkit (WebSocket)
64 µs
Socket.IO 4.8.4
121 µs
gRPC 1.14.7
607 µs
tRPC 11.22.1
1.1 ms

List of 100 objects

One number as argument, 100 user objects as result.

Deepkit (TCP)
177 µs
Deepkit (WebSocket)
193 µs
ws (no framework) 8.22.1
218 µs
Socket.IO 4.8.4
286 µs
gRPC 1.14.7
969 µs
tRPC 11.22.1
1.1 ms

Under load, with 64 connections and 8 calls in flight on each: Deepkit answers 494,277 small calls per second over TCP, 8.5× as many as Socket.IO, 35× gRPC, 115× tRPC and 6.8× plain ws without a framework. With an object as argument and result, it answers 231,119 calls per second over TCP, 6.5× as many as Socket.IO, 19× gRPC, 58× tRPC and 3.8× plain ws without a framework. Over WebSocket, the transport of Socket.IO and ws, it still answers 97,440 small calls per second, 1.7× as many as Socket.IO and 1.3× 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
6.2 µs
Pipe
34 µs
Unix socket
34 µs
Shared memory, no polling
38 µs
MessagePort
42 µs
TCP
43 µs
process.send
61 µs

Object call

A user object as argument and as result.

Shared memory
10 µs
Pipe
39 µs
Unix socket
39 µs
Shared memory, no polling
45 µs
MessagePort
49 µs
TCP
50 µs
process.send
65 µs

List of 100 objects

One number as argument, 100 user objects as result.

Shared memory
140 µs
Pipe
172 µs
Shared memory, no polling
176 µs
Unix socket
177 µs
MessagePort
194 µs
TCP
199 µs
process.send
266 µ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
89 µs
TCP
96 µs
Shared memory, no polling
98 µs
MessagePort
99 µs
process.send
112 µs

A small call to a worker thread over shared memory takes 6.2 µs, 5.6x faster than over a unix socket (34.5 µs) and 7.0x faster than over TCP (43.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
322K ops/s
Redis (node-redis) 6.3.1
309K ops/s
Valkey (ioredis) 5.6.1
272K ops/s
Redis (ioredis) 5.6.1
271K ops/s

Write an object

A user object under a key.

Redis (node-redis) 6.3.1
327K ops/s
Deepkit Broker
291K ops/s
Redis (ioredis) 5.6.1
279K ops/s
Valkey (ioredis) 5.6.1
274K ops/s

Increment

A counter under a key.

Deepkit Broker
371K ops/s
Valkey (ioredis) 5.6.1
306K ops/s
Redis (ioredis) 5.6.1
303K ops/s
Redis (node-redis) 6.3.1
268K ops/s

Publish and receive

A user object, until the subscriber received it.

NATS 3.4.0
289K ops/s
Deepkit Broker
282K ops/s
Redis (ioredis) 5.6.1
242K ops/s
Valkey (ioredis) 5.6.1
230K ops/s
Redis (node-redis) 6.3.1
223K 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 71, slower in 1 and unchanged within the measurement error in 300 of 372 benchmarks.

1.0.181.1.0master
Validation and serialization
is<User>() 409 ns 54 ns 7.7× faster 52 ns +2.5%
validate<User>() with errors 599 ns 184 ns 3.2× faster 187 ns -1.6%
serialize<User>() 632 ns 174 ns 3.6× faster 129 ns 1.4× faster
deserialize<User>() 694 ns 189 ns 3.7× faster 144 ns 1.3× faster
cast<User>() 1.2 µs 393 ns 3.1× faster 269 ns 1.5× faster
deserialize<T[]>(), 100 items 142 µs 9.1 µs 15.7× faster 7.4 µs 1.2× faster
Runtime types
typeOf<Order>() 210 ns 21 ns 10.0× faster 18 ns 1.1× faster
resolveReceiveType<User>() 648 ns 299 ns 2.2× faster 294 ns +1.5%
ReflectionClass.from(), cached 74 ns 72 ns +2.1% 73 ns -0.9%
Change detection
Detect changes, medium entity 542 ns 542 ns +0.1% 538 ns +0.6%
Create snapshot, medium entity 3.6 µs 3.7 µs -2.4% 3.6 µs +2.1%
BSON
Serialize small object 406 ns 400 ns +1.6% 426 ns -6.3%
Deserialize small object 456 ns 449 ns +1.5% 254 ns 1.8× faster
RPC
RPC action call 9.3 µs 9.5 µs -2.0% 922 ns 10.3× faster
HTTP
GET with route parameter 115 µs 117 µs -1.7% 21 µs 5.5× faster
POST with validated JSON body 231 µs 226 µs +2.1% 26 µs 8.6× faster
Route with query string 2.7 µs 1.1 µs 2.3× faster 1.1 µs +1.7%
HTTP body with 10 users 115 µs 4.4 µs 26.4× faster 4.6 µs -4.9%
Serialize API response 270 µs 18 µs 14.8× faster 18 µs +1.7%
Dependency injection, app and events
injector.get() 22 ns 22 ns +0.7% 23 ns -7.1%
injector.get() with dependencies 22 ns 22 ns -0.1% 22 ns +0.3%
Scoped service, new scope 54 ns 54 ns +1.0% 54 ns -0.3%
App with 5 module imports 21 µs 13 µs 1.7× faster 12 µs +6.3%
Event with one listener 17 ns 17 ns -0.4% 18 ns -3.2%
ORM and database
SQLite findOne 66 µs 64 µs +3.8% 12 µs 5.4× faster
Hydrate 100 entities 135 µs 78 µs 1.7× faster 79 µs -0.4%
MongoDB insert of 100 entities 2.0 ms 2.0 ms +0.9% 1.5 ms 1.4× faster
MongoDB deleteMany of 1,000 documents – – 7.0 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.91 s2.06 s+7.9%-0.4%
http16 files · 4,054 lines126.5 KB175.1 KB+38.5%+48.3%+0.1 points2.00 s2.65 s+32.5%-5.0%
framework29 files · 3,815 lines139.5 KB181.6 KB+30.2%+38.4%+1.8 points2.68 s3.41 s+26.9%-1.9%
type27 files · 12,997 lines469.6 KB578.2 KB+23.1%+30.7%+0.5 points3.42 s4.15 s+21.4%+1.0%

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 µs35.0K ops/s -0.4%
createModule - with providers28 µs35.7K ops/s -0.1%
module class instantiation1.8 µs550K ops/s +8.9%
module class with config1.8 µs547K ops/s +7.3%
App creation - empty1.5 µs680K ops/s -0.3%
App creation - with providers2.0 µs492K ops/s +2.6%
App creation - with imports3.8 µs263K ops/s +2.3%
App.get() - resolve service136 ns7.3M ops/s -6.6%
App.get() - from imported module47 ns21.4M ops/s -0.5%
App.configure()2.5 µs401K ops/s +5.5%
App creation - nested imports5.5 µs183K ops/s +1.8%
App.setup() chain2.0 µs502K ops/s -3.5%
Module.configure()2.6 µs389K ops/s +3.4%
AppModule direct instantiation1.5 µs663K ops/s -2.0%
App creation - 5 module imports12 µs83.5K ops/s +6.3%
BSON16 benchmarks · packages/bson/benchmarks/bson.bench.ts
serialize small object426 ns2.3M ops/s -6.3%
deserialize small object254 ns3.9M ops/s 1.8× faster
serialize object with dates560 ns1.8M ops/s 1.2× slower
deserialize object with dates608 ns1.6M ops/s 1.4× faster
serialize nested object820 ns1.2M ops/s 1.2× faster
deserialize nested object688 ns1.5M ops/s 1.5× faster
serialize array (1000 items)554 µs1.8K ops/s 1.3× faster
deserialize array (1000 items)480 µs2.1K ops/s 1.7× faster
serialize array (5000 items)2.8 ms361 ops/s 1.3× faster
deserialize array (5000 items)2.4 ms416 ops/s 2.0× faster
serialize number array (1000)45 µs22.2K ops/s 1.4× faster
deserialize number array (1000)27 µs37.7K ops/s -1.1%
serialize string array (1000)124 µs8.1K ops/s 4.3× faster
deserialize string array (1000)155 µs6.5K ops/s 1.8× faster
serialize complex document2.0 µs500K ops/s 1.6× faster
deserialize complex document2.8 µs360K ops/s 1.4× faster
Events9 benchmarks · packages/event/benchmarks/event.bench.ts
sync event - single listener18 ns56.4M ops/s -3.2%
sync event - no listeners19 ns53.3M ops/s -4.5%
async event - single sync listener355 ns2.8M ops/s -0.8%
async event - single async listener375 ns2.7M ops/s +0.4%
async event - 10 listeners1.2 µs869K ops/s +1.3%
data event - with payload451 ns2.2M ops/s +2.8%
sync event - pre-compiled dispatcher20 ns49.0M ops/s -0.4%
sync event - with propagation stop80 ns12.5M ops/s +0.2%
dispatcher creation + listener add420 ns2.4M ops/s +0.0%
HTTP router and serialization28 benchmarks · packages/http/benchmarks/http.bench.ts
route match - simple static149 ns6.7M ops/s +0.9%
route match - single param208 ns4.8M ops/s +1.1%
route match - multi param278 ns3.6M ops/s -0.1%
route match - with query1.1 µs883K ops/s +0.4%
route match - many routes (first)69 ns14.5M ops/s -2.2%
route match - many routes (middle)130 ns7.7M ops/s -1.8%
route match - many routes (last)353 ns2.8M ops/s +0.6%
route match - not found208 ns4.8M ops/s +0.8%
resolve request - simple43 ns23.0M ops/s +5.5%
resolve request - with params185 ns5.4M ops/s 1.3× faster
resolve request - with query1.1 µs896K ops/s +1.7%
serialize - single user1.6 µs627K ops/s +1.1%
serialize - user array (10)16 µs62.7K ops/s +1.2%
serialize - api response18 µs55.8K ops/s +1.7%
JSON.stringify - single user3.0 µs335K ops/s -1.4%
JSON.stringify - user array (10)23 µs43.2K ops/s -1.7%
deserialize - single user463 ns2.2M ops/s -1.1%
deserialize - user array (10)4.6 µs218K ops/s -4.9%
JSON.parse - single user798 ns1.3M ops/s +0.3%
create router registry12 ns84.6M ops/s 1.1× faster
registry - add GET route310 ns3.2M ops/s -0.3%
registry - add 5 routes1.3 µs773K ops/s -0.3%
resolveUrl - single param5.5 ns183M ops/s +0.0%
resolveUrl - multi param8.9 ns112M ops/s +0.9%
middleware config - create7.5 µs133K ops/s -1.1%
middleware config - with route filter15 µs67.7K ops/s +0.4%
read controller metadata39 ns25.5M ops/s 1.1× faster
get routes from router0.7 ns1357M ops/s +0.0%
Dependency injection10 benchmarks · packages/injector/benchmarks/injector.bench.ts
baseline: new Database()0.7 ns1345M ops/s +0.0%
get simple provider23 ns43.1M ops/s -7.1%
get provider with dependencies22 ns46.4M ops/s +0.3%
get via resolver function0.7 ns1362M ops/s +0.0%
scoped: same scope (cached)39 ns25.9M ops/s +2.8%
scoped: new scope each call54 ns18.6M ops/s -0.3%
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.5%
createChildScope().getInjector()15 ns67.8M ops/s -3.3%
Dependency injection: scaling26 benchmarks · packages/injector/benchmarks/scaling.bench.ts
10 providers: get()9.7 ns104M ops/s -0.0%
10 providers: resolver()0.7 ns1361M ops/s +1.2%
50 providers: get()9.7 ns104M ops/s +0.0%
50 providers: resolver()0.7 ns1339M ops/s +0.0%
100 providers: get()9.7 ns104M ops/s +0.0%
100 providers: resolver()0.7 ns1339M ops/s 1.3× faster
200 providers: get()9.6 ns104M ops/s +0.0%
200 providers: resolver()0.7 ns1339M ops/s +0.2%
500 providers: get()9.7 ns104M ops/s +0.2%
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 ns104M ops/s +0.1%
singleton: get()22 ns46.2M ops/s -0.2%
scoped: same scope get()44 ns22.7M ops/s -3.7%
scoped: new scope + get()144 ns6.9M ops/s -2.3%
tag injection: get service with tags9.7 ns103M ops/s -0.4%
transient: get() (new instance)56 ns18.0M ops/s +1.3%
non-transient: get() (cached)22 ns45.9M ops/s +0.2%
resolver caching: direct get()9.7 ns104M ops/s +0.1%
resolver caching: cached resolver()0.7 ns1362M ops/s +0.1%
resolver caching: context.resolve()0.7 ns1345M ops/s -1.1%
injector creation: 10 providers145 µs6.9K ops/s +1.4%
injector creation: 100 providers7.7 ms131 ops/s +0.3%
injector creation: 500 providers83 ms12.0 ops/s +1.0%
Logger14 benchmarks · packages/logger/benchmarks/logger.bench.ts
log info - no formatter230 ns4.3M ops/s 1.1× faster
log info - default formatter2.7 µs367K ops/s -0.7%
log info - color formatter1.4 µs716K ops/s +1.5%
log debug level243 ns4.1M ops/s +2.7%
log warning level243 ns4.1M ops/s +2.9%
log error level243 ns4.1M ops/s +2.9%
log info - disabled (filtered)23 ns43.0M ops/s -5.7%
scoped logger - info1.4 µs690K ops/s +0.0%
scoped logger creation (cached)0.7 ns1362M ops/s +2.1%
log with format args697 ns1.4M ops/s +3.1%
log with data359 ns2.8M ops/s +2.4%
memory logger - info552 ns1.8M ops/s +5.6%
log info - 3 transports488 ns2.0M ops/s -0.4%
logger.is() check5.2 ns194M ops/s -0.1%
ORM with MongoDB8 benchmarks · packages/mongo/benchmarks/mongo.bench.ts
convert filter (no database)1.6 µs639K ops/s +5.7%
findOne by _id213 µs4.7K ops/s 1.5× faster
count with filter5.8 ms173 ops/s 4.9× faster
insert one211 µs4.7K ops/s 1.4× faster
insert 100 in one session1.5 ms687 ops/s 1.4× faster
patchOne365 µs2.7K ops/s +6.3%
change detection + update of a loaded entity765 µs1.3K ops/s 1.1× faster
deleteMany 1,000 rows7.0 ms142 ops/s new
RPC actions20 benchmarks · packages/rpc/benchmarks/actions.bench.ts
simple: ping (no args, string return)950 ns1.1M ops/s 11.0× faster
simple: echo (string arg, string return)1.1 µs927K ops/s 9.1× faster
simple: add (2 number args, number return)922 ns1.1M ops/s 10.3× faster
simple: validateNumber (with validation)1.1 µs908K ops/s 9.2× faster
user: getUser (entity return)2.1 µs468K ops/s 7.2× faster
user: createUser (2 string args, entity return)2.3 µs431K ops/s 7.3× faster
product: getProduct (entity return)2.0 µs497K ops/s 10.2× faster
product: createProduct (complex args, entity return)3.2 µs310K ops/s 6.1× faster
user: listUsers (complex result with array)10.0 µs100K ops/s 3.9× faster
product: search (object args, array return)11 µs91.5K ops/s 4.3× faster
user: processUsers (2 items)2.8 µs354K ops/s 6.3× faster
user: processUsers (10 items)8.2 µs122K ops/s 4.5× faster
user: processUsers (100 items)70 µs14.2K ops/s 3.2× faster
product: bulkCreate (2 items)2.9 µs340K ops/s 7.4× faster
product: bulkCreate (10 items)10 µs96.9K ops/s 4.2× faster
type cache: first call (cold)659 µs1.5K ops/s 1.6× slower
type cache: subsequent calls (warm)952 ns1.1M ops/s 10.0× faster
sequential: 5 simple calls4.4 µs227K ops/s 10.6× faster
sequential: 5 entity calls10 µs97.8K ops/s 7.8× faster
connect + call + disconnect615 µs1.6K 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 entity779 ns1.3M ops/s +1.5%
deserialize 100 entities79 µs12.7K ops/s -0.4%
cast single entity1.2 µs847K ops/s +1.7%
serialize single entity2.0 µs492K ops/s -0.4%
create query364 ns2.7M ops/s 2.7× faster
query with filter450 ns2.2M ops/s 4.9× faster
query with multiple filters1.0 µs968K ops/s 5.9× faster
query with select730 ns1.4M ops/s 3.4× faster
clone query111 ns9.0M ops/s 10.6× faster
create session99 ns10.1M ops/s 1.7× faster
session add item809 ns1.2M ops/s -7.4%
session add 10 items4.0 µs250K ops/s 1.3× faster
query count4.2 µs238K ops/s 4.0× faster
query findOne12 µs85.4K ops/s 5.4× faster
query find (limit 10)41 µs24.3K ops/s 2.2× faster
query find with filter43 µs23.4K ops/s 2.5× faster
insert single item55 µs18.3K ops/s 1.2× faster
patch single item221 µs4.5K ops/s +6.4%
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 µs274K ops/s +2.1%
createSnapshot (large entity)5.9 µs169K ops/s +6.8%
detect changes (no changes, small)35 ns28.2M ops/s -0.3%
detect changes (no changes, medium)316 ns3.2M ops/s -0.3%
detect changes (no changes, large)929 ns1.1M ops/s +5.9%
detect changes (with changes, small)174 ns5.7M ops/s +0.2%
detect changes (with changes, medium)538 ns1.9M ops/s +0.6%
detect changes (with changes, large)1.6 µs643K ops/s -0.3%
extract primary key (small)1.6 ns634M ops/s +0.1%
extract primary key (medium)1.7 ns604M ops/s +0.7%
extract primary key (large)27 ns37.3M ops/s +1.2%
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.9M ops/s -1.5%
buildChanges (no changes, small)209 ns4.8M ops/s +0.3%
buildChanges (no changes, medium)4.3 µs235K ops/s +1.2%
buildChanges (no changes, large)12 µs80.2K ops/s 1.6× slower
buildChanges (with changes, small)280 ns3.6M ops/s 1.1× faster
buildChanges (with changes, medium)4.5 µs224K ops/s +1.2%
buildChanges (with changes, large)8.7 µs115K ops/s +0.1%
Runtime types37 benchmarks · packages/type/benchmarks/reflection.bench.ts
ReflectionClass.from (cached)73 ns13.7M ops/s -0.9%
typeOf<string>776 ns1.3M ops/s +2.5%
typeOf<number>814 ns1.2M ops/s +0.6%
typeOf<User>281 ns3.6M ops/s +2.2%
typeOf<Product>7.7 ns130M ops/s +0.4%
typeOf<Order>18 ns54.6M ops/s 1.1× faster
typeOf<PaymentMethod>18 ns54.5M ops/s +9.8%
typeOf<User[]>2.0 µs498K ops/s +2.0%
typeOf<Map<string, User>>2.3 µs437K ops/s +9.6%
reflect(User)184 ns5.4M ops/s +0.3%
reflect(function)183 ns5.5M ops/s +1.0%
resolveReceiveType<string>15 ns66.1M ops/s +0.3%
resolveReceiveType<User>294 ns3.4M ops/s +1.5%
getProperties()0.7 ns1357M ops/s +0.1%
getPropertyNames()0.7 ns1357M ops/s +0.1%
getProperty(name)21 ns46.8M ops/s -4.0%
hasProperty(name)25 ns39.6M ops/s -0.1%
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.7M ops/s +0.0%
hasMethod(name)21 ns46.9M ops/s +0.0%
method.getParameters()24 ns41.8M ops/s -0.1%
type.kind === ReflectionKind.string3.4 ns297M ops/s -0.0%
type.kind === ReflectionKind.class3.4 ns298M ops/s +0.0%
type.kind === ReflectionKind.union3.4 ns298M ops/s +0.0%
type.kind === ReflectionKind.array3.4 ns298M ops/s +0.1%
property.isOptional()0.7 ns1356M 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)298 ns3.4M ops/s -2.3%
function.getParameters()0.7 ns1351M ops/s +0.0%
function.getReturnType()0.7 ns1356M ops/s -0.0%
reflection.getClassName()4.2 ns238M ops/s +0.0%
reflection.getClassType()3.8 ns265M ops/s +0.1%
reflection.getConstructorOrUndefined()9.6 ns104M ops/s +0.1%
Serialization24 benchmarks · packages/type/benchmarks/serialization.bench.ts
deepkit small deserialize460 ns2.2M ops/s 1.1× faster
deepkit small serialize544 ns1.8M ops/s -2.7%
deepkit medium deserialize870 ns1.1M ops/s 1.3× faster
deepkit medium serialize2.4 µs422K ops/s 1.1× faster
deepkit large deserialize5.2 µs191K ops/s +2.8%
deepkit large serialize12 µs80.6K ops/s 1.1× faster
deepkit array[100] deserialize7.4 µs135K ops/s 1.2× faster
deepkit array[100] serialize7.4 µs134K ops/s 1.3× faster
deepkit array[1000] deserialize161 µs6.2K ops/s 1.7× slower
deepkit array[1000] serialize78 µs12.8K ops/s 1.2× faster
deepkit array[10000] deserialize771 µs1.3K ops/s 2.5× faster
deepkit array[10000] serialize798 µs1.3K ops/s 1.4× faster
deepkit deeply-nested deserialize941 ns1.1M ops/s 1.1× faster
deepkit deeply-nested serialize2.1 µs476K ops/s +5.7%
deepkit union-types deserialize929 ns1.1M ops/s 1.3× faster
deepkit union-types serialize1.1 µs937K ops/s 1.3× faster
deepkit special-types deserialize4.0 µs249K ops/s -0.6%
deepkit special-types serialize9.0 µs111K ops/s +1.9%
deepkit tree-structure deserialize1.2 µs837K ops/s +8.6%
deepkit tree-structure serialize1.1 µs882K ops/s 1.2× faster
deepkit linked-list deserialize679 ns1.5M ops/s +6.7%
deepkit linked-list serialize649 ns1.5M ops/s +5.3%
deepkit category-hierarchy deserialize1.2 µs852K ops/s 1.1× faster
deepkit category-hierarchy serialize1.2 µs866K ops/s +7.8%
Unions3 benchmarks · packages/type/benchmarks/union.bench.ts
guard union (rotating members)51 ns19.6M ops/s +0.3%
guard union text only44 ns22.7M ops/s +0.7%
deserialize union285 ns3.5M ops/s +0.3%
Validation33 benchmarks · packages/type/benchmarks/validation.bench.ts
guard (valid)35 ns28.5M ops/s -0.6%
guard (invalid)40 ns24.7M ops/s +1.5%
validate (valid)38 ns26.4M ops/s +0.8%
validate (invalid)141 ns7.1M ops/s -0.8%
is (valid, no errors)62 ns16.2M ops/s +1.4%
is (invalid, no errors)70 ns14.4M ops/s +3.5%
is (valid, with errors)70 ns14.3M ops/s +0.3%
is (invalid, with errors)155 ns6.4M ops/s -1.9%
assert (valid)82 ns12.2M ops/s +2.9%
assert (invalid, try-catch)6.7 µs149K ops/s +3.2%
constraints (valid)239 ns4.2M ops/s -0.1%
constraints (invalid)394 ns2.5M ops/s -0.0%
constraints validate (invalid)818 ns1.2M ops/s +0.4%
array objects (valid)119 ns8.4M ops/s +1.3%
array objects (invalid)328 ns3.1M ops/s +1.6%
array objects validate (invalid)1.6 µs625K ops/s -0.1%
large array (100 items)3.2 µs310K ops/s +0.6%
deep nested (valid)718 ns1.4M ops/s +1.1%
deep nested (invalid)936 ns1.1M ops/s -0.2%
deep nested validate (invalid)2.9 µs347K ops/s 1.1× faster
union text (valid)25 ns39.5M ops/s 1.2× faster
union image (valid)31 ns32.3M ops/s -0.4%
union video (valid)30 ns33.9M ops/s +0.4%
union file (valid)32 ns31.0M ops/s -0.8%
union text (invalid)116 ns8.6M ops/s +0.2%
union image (invalid)125 ns8.0M ops/s +0.5%
union validate (invalid)646 ns1.5M ops/s -0.4%
overhead: guard (valid)36 ns28.1M ops/s +0.7%
overhead: validate (valid)42 ns23.8M ops/s -1.0%
overhead: guard (invalid)44 ns22.7M ops/s +0.1%
overhead: validate (invalid)127 ns7.8M ops/s -2.0%
overhead: guard (many errors)377 ns2.7M ops/s -4.1%
overhead: validate (many errors)1.1 µs885K ops/s 1.3× slower
HTTP requests5 benchmarks · packages/http/benchmarks/kernel.bench.ts
GET with route parameter21 µs46.9K ops/s 5.5× faster
GET list of 10 with query parameter49 µs20.5K ops/s 3.2× faster
POST with validated JSON body26 µs38.0K ops/s 8.6× faster
validation error (400)32 µs31.3K ops/s 3.5× faster
not found (404)12 µs81.2K ops/s 6.5× faster

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