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.

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

Compared with other libraries

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.

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.4M ops/s 24 ns
ArkType 2.2.9
26.0M ops/s 38 ns
TypeBox 0.34.52
26.0M ops/s 38 ns
Deepkit guard()
25.1M ops/s 40 ns
Deepkit is()
20.3M ops/s 49 ns
Zod 4.6.7
3.9M ops/s 257 ns
Valibot 1.5.0
675K ops/s 1.5 µs
class-validator 0.15.1
36.1K ops/s 28 µs

Validation errors

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

Deepkit validate()
5.4M ops/s 184 ns
typia (AOT) 15.2.0
1.0M ops/s 992 ns
Zod 4.6.7
721K ops/s 1.4 µs
Valibot 1.5.0
529K ops/s 1.9 µs
TypeBox 0.34.52
119K ops/s 8.4 µs
ArkType 2.2.9
50.7K ops/s 20 µs
class-validator 0.15.1
36.8K ops/s 27 µs

Deserialization

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

Deepkit deserialize()
5.2M ops/s 191 ns
Deepkit cast() with validation
2.6M ops/s 391 ns
class-transformer 0.5.1
85.9K ops/s 12 µs

Serialization to JSON

A typed object to a JSON string.

JSON.stringify (no types)
1.4M ops/s 692 ns
Deepkit + JSON.stringify
1.2M ops/s 829 ns
typia json.stringify 15.2.0
1.0M ops/s 968 ns

BSON

Encoding and decoding of the same object to BSON, compared with the official bson package of the MongoDB driver.

Deepkit serialize
571K ops/s 1.8 µs
Deepkit deserialize
463K ops/s 2.2 µs
bson deserialize 7.3.3
233K ops/s 4.3 µs
bson serialize 7.3.3
210K ops/s 4.8 µ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.

PostgreSQL

findOne by id

A row by its primary key.

postgres.js (driver) 3.4.9
111 µs
pg (driver) 8.23.1
113 µs
Deepkit
377 µs
Sequelize 6.37.8
424 µs
Drizzle 0.45.4
431 µs
TypeORM 1.1.2
446 µs
Prisma 7.10.1
533 µs
MikroORM 7.2.5
603 µs

Load 10,000 rows

All rows of the table as objects.

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

Insert 1,000 rows

In one unit of work or batch, then deleted again.

pg (driver) 8.23.1
48 ms
postgres.js (driver) 3.4.9
51 ms
Deepkit
62 ms
Sequelize 6.37.8
64 ms
TypeORM 1.1.2
73 ms
MikroORM 7.2.5
75 ms
Drizzle 0.45.4
85 ms
Prisma 7.10.1
126 ms

SQLite

findOne by id

A row by its primary key.

better-sqlite3 (driver) 12.11.1
15 µs
Deepkit
87 µs
Drizzle 0.45.4
113 µs
TypeORM 1.1.2
118 µs
Prisma 7.10.1
195 µs
MikroORM 7.2.5
303 µs
Sequelize 6.37.8
548 µs

Load 10,000 rows

All rows of the table as objects.

better-sqlite3 (driver) 12.11.1
6.3 ms
Drizzle 0.45.4
11 ms
Deepkit
14 ms
TypeORM 1.1.2
17 ms
Prisma 7.10.1
19 ms
Sequelize 6.37.8
79 ms
MikroORM 7.2.5
118 ms

Insert 1,000 rows

In one unit of work or batch, then deleted again.

better-sqlite3 (driver) 12.11.1
2.2 ms
Deepkit
6.0 ms
Sequelize 6.37.8
9.5 ms
TypeORM 1.1.2
10 ms
Drizzle 0.45.4
16 ms
MikroORM 7.2.5
16 ms
Prisma 7.10.1
63 ms

MongoDB

findOne by id

A row by its primary key.

Deepkit
299 µs
mongodb (driver) 7.7.0
428 µs
Mongoose 9.11.4
492 µs
MikroORM 7.2.5
638 µs

Load 10,000 rows

All rows of the table as objects.

mongodb (driver) 7.7.0
25 ms
Deepkit
31 ms
Mongoose 9.11.4
79 ms
MikroORM 7.2.5
140 ms

Insert 1,000 rows

In one unit of work or batch, then deleted again.

mongodb (driver) 7.7.0
14 ms
Deepkit
22 ms
MikroORM 7.2.5
31 ms
Mongoose 9.11.4
33 ms

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.0.19, master is faster in 83, slower in 4 and unchanged within the measurement error in 316 of 403 benchmarks.

1.0.181.0.19master
is<User>() 409 ns 411 ns no change 49 ns 8.3× faster
validate<User>() with errors 599 ns 618 ns no change 184 ns 3.4× faster
serialize<User>() 632 ns 642 ns no change 177 ns 3.6× faster
deserialize<User>() 694 ns 690 ns no change 191 ns 3.6× faster
cast<User>() 1.2 µs 1.2 µs no change 391 ns 3.1× faster
deserialize<T[]>(), 100 items 142 µs 143 µs no change 9.0 µs 15.8× faster
HTTP body with 10 users 115 µs 111 µs no change 4.4 µs 25.5× faster
RPC message with body 229 ns 226 ns no change 9.8 ns 23.1× faster

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.0.19), 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 count as no change.

App modules15 benchmarks · packages/app/benchmarks/app.bench.ts
createModule - empty29 µs34.8K ops/s no change
createModule - with providers28 µs35.5K ops/s no change
module class instantiation1.9 µs517K ops/s no change
module class with config1.9 µs539K ops/s no change
App creation - empty1.5 µs659K ops/s +20%
App creation - with providers2.0 µs493K ops/s +12%
App creation - with imports4.0 µs253K ops/s no change
App.get() - resolve service130 ns7.7M ops/s no change
App.get() - from imported module47 ns21.3M ops/s no change
App.configure()2.6 µs384K ops/s no change
App creation - nested imports6.0 µs168K ops/s no change
App.setup() chain2.0 µs490K ops/s no change
Module.configure()2.6 µs385K ops/s no change
AppModule direct instantiation1.5 µs661K ops/s no change
App creation - 5 module imports12 µs80.4K ops/s no change
BSON16 benchmarks · packages/bson/benchmarks/bson.bench.ts
serialize small object396 ns2.5M ops/s no change
deserialize small object449 ns2.2M ops/s no change
serialize object with dates481 ns2.1M ops/s no change
deserialize object with dates856 ns1.2M ops/s no change
serialize nested object958 ns1.0M ops/s no change
deserialize nested object1.0 µs986K ops/s no change
serialize array (1000 items)703 µs1.4K ops/s no change
deserialize array (1000 items)677 µs1.5K ops/s no change
serialize array (5000 items)3.6 ms282 ops/s no change
deserialize array (5000 items)4.2 ms240 ops/s no change
serialize number array (1000)64 µs15.7K ops/s no change
deserialize number array (1000)26 µs38.1K ops/s no change
serialize string array (1000)529 µs1.9K ops/s no change
deserialize string array (1000)277 µs3.6K ops/s no change
serialize complex document3.1 µs325K ops/s no change
deserialize complex document3.7 µs271K ops/s no change
Events9 benchmarks · packages/event/benchmarks/event.bench.ts
sync event - single listener17 ns58.0M ops/s no change
sync event - no listeners18 ns55.4M ops/s no change
async event - single sync listener364 ns2.7M ops/s no change
async event - single async listener387 ns2.6M ops/s no change
async event - 10 listeners1.2 µs829K ops/s no change
data event - with payload467 ns2.1M ops/s no change
sync event - pre-compiled dispatcher21 ns48.0M ops/s no change
sync event - with propagation stop82 ns12.2M ops/s no change
dispatcher creation + listener add431 ns2.3M ops/s no change
HTTP router and serialization28 benchmarks · packages/http/benchmarks/http.bench.ts
route match - simple static155 ns6.4M ops/s no change
route match - single param208 ns4.8M ops/s no change
route match - multi param281 ns3.6M ops/s no change
route match - with query1.1 µs879K ops/s +136%
route match - many routes (first)69 ns14.5M ops/s no change
route match - many routes (middle)135 ns7.4M ops/s no change
route match - many routes (last)355 ns2.8M ops/s no change
route match - not found209 ns4.8M ops/s no change
resolve request - simple45 ns22.1M ops/s no change
resolve request - with params189 ns5.3M ops/s no change
resolve request - with query1.1 µs893K ops/s +140%
serialize - single user1.7 µs605K ops/s +30%
serialize - user array (10)16 µs61.9K ops/s +544%
serialize - api response18 µs55.0K ops/s +954%
JSON.stringify - single user3.0 µs337K ops/s no change
JSON.stringify - user array (10)23 µs43.9K ops/s no change
deserialize - single user463 ns2.2M ops/s +97%
deserialize - user array (10)4.4 µs230K ops/s +2451%
JSON.parse - single user789 ns1.3M ops/s no change
create router registry11 ns88.2M ops/s no change
registry - add GET route330 ns3.0M ops/s no change
registry - add 5 routes1.4 µs727K ops/s no change
resolveUrl - single param6.2 ns162M ops/s no change
resolveUrl - multi param10 ns98.1M ops/s no change
middleware config - create7.5 µs133K ops/s no change
middleware config - with route filter15 µs67.4K ops/s no change
read controller metadata41 ns24.6M ops/s no change
get routes from router0.7 ns1357M ops/s no change
HTTP requests5 benchmarks · packages/http/benchmarks/kernel.bench.ts
GET with route parameter118 µs8.5K ops/s no change
GET list of 10 with query parameter155 µs6.5K ops/s no change
POST with validated JSON body225 µs4.5K ops/s no change
validation error (400)112 µs8.9K ops/s no change
not found (404)79 µs12.7K ops/s no change
Dependency injection10 benchmarks · packages/injector/benchmarks/injector.bench.ts
baseline: new Database()1.0 ns1003M ops/s no change
get simple provider22 ns46.4M ops/s no change
get provider with dependencies22 ns46.3M ops/s no change
get via resolver function0.7 ns1361M ops/s no change
scoped: same scope (cached)39 ns25.8M ops/s no change
scoped: new scope each call55 ns18.3M ops/s no change
context.getInjector().get()24 ns41.2M ops/s no change
new InjectorContext(module)2.1 ns467M ops/s no change
createChildScope()2.2 ns460M ops/s no change
createChildScope().getInjector()14 ns69.1M ops/s no change
Dependency injection: scaling26 benchmarks · packages/injector/benchmarks/scaling.bench.ts
10 providers: get()9.7 ns104M ops/s no change
10 providers: resolver()0.7 ns1362M ops/s no change
50 providers: get()9.7 ns104M ops/s no change
50 providers: resolver()0.7 ns1339M ops/s no change
100 providers: get()9.7 ns104M ops/s no change
100 providers: resolver()0.7 ns1339M ops/s no change
200 providers: get()9.7 ns104M ops/s no change
200 providers: resolver()0.7 ns1339M ops/s no change
500 providers: get()9.6 ns104M ops/s no change
500 providers: resolver()0.7 ns1338M ops/s no change
chain depth 1: get()9.7 ns104M ops/s no change
chain depth 3: get()9.7 ns104M ops/s no change
chain depth 5: get()9.7 ns104M ops/s no change
chain depth 10: get()9.7 ns104M ops/s no change
singleton: get()22 ns45.6M ops/s no change
scoped: same scope get()43 ns23.3M ops/s no change
scoped: new scope + get()142 ns7.0M ops/s no change
tag injection: get service with tags9.7 ns104M ops/s no change
transient: get() (new instance)59 ns17.1M ops/s no change
non-transient: get() (cached)22 ns46.4M ops/s no change
resolver caching: direct get()9.7 ns104M ops/s no change
resolver caching: cached resolver()0.7 ns1353M ops/s no change
resolver caching: context.resolve()0.7 ns1361M ops/s no change
injector creation: 10 providers147 µs6.8K ops/s no change
injector creation: 100 providers7.6 ms131 ops/s no change
injector creation: 500 providers83 ms12.0 ops/s +81%
Logger14 benchmarks · packages/logger/benchmarks/logger.bench.ts
log info - no formatter249 ns4.0M ops/s no change
log info - default formatter2.8 µs356K ops/s no change
log info - color formatter1.4 µs703K ops/s no change
log debug level262 ns3.8M ops/s +12%
log warning level261 ns3.8M ops/s +10%
log error level263 ns3.8M ops/s +9%
log info - disabled (filtered)26 ns38.5M ops/s no change
scoped logger - info1.5 µs656K ops/s no change
scoped logger creation (cached)0.7 ns1362M ops/s no change
log with format args712 ns1.4M ops/s no change
log with data387 ns2.6M ops/s +6%
memory logger - info609 ns1.6M ops/s no change
log info - 3 transports509 ns2.0M ops/s no change
logger.is() check5.2 ns194M ops/s no change
ORM with MongoDB9 benchmarks · packages/mongo/benchmarks/mongo.bench.ts
convert filter (no database)1.6 µs620K ops/s no change
findOne by _id360 µs2.8K ops/s no change
find 100 with hydration1.2 ms814 ops/s no change
find 100 without hydration (lean)1.2 ms838 ops/s no change
count with filter849 µs1.2K ops/s no change
insert one313 µs3.2K ops/s no change
insert 100 in one session2.1 ms473 ops/s no change
patchOne400 µs2.5K ops/s no change
change detection + update of a loaded entity864 µs1.2K ops/s no change
RPC actions20 benchmarks · packages/rpc/benchmarks/actions.bench.ts
simple: ping (no args, string return)10 µs95.4K ops/s no change
simple: echo (string arg, string return)10 µs98.5K ops/s no change
simple: add (2 number args, number return)9.2 µs109K ops/s no change
simple: validateNumber (with validation)10 µs96.5K ops/s no change
user: getUser (entity return)16 µs61.6K ops/s no change
user: createUser (2 string args, entity return)17 µs57.5K ops/s no change
product: getProduct (entity return)21 µs47.7K ops/s no change
product: createProduct (complex args, entity return)21 µs48.6K ops/s no change
user: listUsers (complex result with array)39 µs25.9K ops/s no change
product: search (object args, array return)45 µs22.0K ops/s no change
user: processUsers (2 items)19 µs51.5K ops/s no change
user: processUsers (10 items)37 µs26.9K ops/s no change
user: processUsers (100 items)217 µs4.6K ops/s no change
product: bulkCreate (2 items)22 µs44.9K ops/s no change
product: bulkCreate (10 items)44 µs22.9K ops/s no change
type cache: first call (cold)694 µs1.4K ops/s no change
type cache: subsequent calls (warm)10 µs96.3K ops/s no change
sequential: 5 simple calls49 µs20.6K ops/s no change
sequential: 5 entity calls85 µs11.8K ops/s no change
connect + call + disconnect479 µs2.1K ops/s no change
RPC messages29 benchmarks · packages/rpc/benchmarks/messages.bench.ts
createRpcMessage (no body)5.9 ns170M ops/s -14%
createRpcMessage small body9.8 ns102M ops/s +2206%
createRpcMessage medium body9.7 ns103M ops/s +3192%
createRpcMessage large body9.7 ns103M ops/s +2173%
serialize (no body)89 ns11.2M ops/s -25%
serialize small body396 ns2.5M ops/s no change
serialize medium body2.0 µs488K ops/s no change
serialize large body236 µs4.2K ops/s no change
deserialize (no body)137 ns7.3M ops/s no change
deserialize small (header only)142 ns7.1M ops/s no change
deserialize medium (header only)141 ns7.1M ops/s no change
deserialize large (header only)140 ns7.1M ops/s no change
parseBody small239 ns4.2M ops/s +106%
parseBody medium2.1 µs470K ops/s +25%
parseBody large291 µs3.4K ops/s no change
decodeBody small (cached decoder)156 ns6.4M ops/s no change
decodeBody medium (cached decoder)2.0 µs503K ops/s no change
decodeBody large (cached decoder)297 µs3.4K ops/s no change
round-trip small1.0 µs977K ops/s no change
round-trip medium5.1 µs198K ops/s no change
create + serialize sourceDest message573 ns1.7M ops/s +60%
deserialize + parse sourceDest message469 ns2.1M ops/s +50%
serialize composite message1.2 µs856K ops/s no change
deserialize + getBodies composite338 ns3.0M ops/s no change
deserialize + getBodies + parseBody composite998 ns1.0M ops/s +50%
serialize RpcTypes.Ack104 ns9.6M ops/s -36%
serialize RpcTypes.Ping95 ns10.5M ops/s -29%
serialize RpcTypes.Action1.1 µs943K ops/s no change
serialize RpcTypes.ResponseActionSimple1.2 µs828K ops/s no change
ORM with SQLite18 benchmarks · packages/sqlite/benchmarks/orm.bench.ts
deserialize single entity798 ns1.3M ops/s +75%
deserialize 100 entities79 µs12.6K ops/s +73%
cast single entity1.2 µs829K ops/s +81%
serialize single entity2.1 µs478K ops/s +26%
create query1.4 µs724K ops/s no change
query with filter2.7 µs365K ops/s no change
query with multiple filters8.0 µs125K ops/s no change
query with select4.4 µs229K ops/s no change
clone query1.4 µs730K ops/s no change
create session201 ns5.0M ops/s no change
session add item893 ns1.1M ops/s no change
session add 10 items5.7 µs174K ops/s no change
query count17 µs59.3K ops/s no change
query findOne65 µs15.5K ops/s no change
query find (limit 10)92 µs10.9K ops/s no change
query find with filter107 µs9.3K ops/s no change
insert single item68 µs14.6K ops/s no change
patch single item228 µs4.4K ops/s no change
Change detection21 benchmarks · packages/type/benchmarks/change-detection.bench.ts
createSnapshot (small entity)8.4 ns119M ops/s no change
createSnapshot (medium entity)3.6 µs279K ops/s no change
createSnapshot (large entity)6.0 µs168K ops/s no change
detect changes (no changes, small)35 ns28.7M ops/s no change
detect changes (no changes, medium)314 ns3.2M ops/s no change
detect changes (no changes, large)932 ns1.1M ops/s no change
detect changes (with changes, small)174 ns5.8M ops/s no change
detect changes (with changes, medium)542 ns1.8M ops/s no change
detect changes (with changes, large)1.6 µs640K ops/s no change
extract primary key (small)1.6 ns630M ops/s no change
extract primary key (medium)1.7 ns593M ops/s no change
extract primary key (large)29 ns34.9M ops/s no change
generate PK hash (small)5.0 ns198M ops/s no change
generate PK hash (medium)5.1 ns197M ops/s no change
generate PK hash (large)28 ns36.0M ops/s no change
buildChanges (no changes, small)213 ns4.7M ops/s no change
buildChanges (no changes, medium)4.2 µs238K ops/s no change
buildChanges (no changes, large)7.8 µs128K ops/s no change
buildChanges (with changes, small)274 ns3.6M ops/s no change
buildChanges (with changes, medium)4.4 µs227K ops/s no change
buildChanges (with changes, large)8.3 µs121K ops/s no change
Runtime types37 benchmarks · packages/type/benchmarks/reflection.bench.ts
ReflectionClass.from (cached)74 ns13.6M ops/s no change
typeOf<string>773 ns1.3M ops/s no change
typeOf<number>805 ns1.2M ops/s no change
typeOf<User>289 ns3.5M ops/s +115%
typeOf<Product>7.7 ns129M ops/s +2599%
typeOf<Order>18 ns54.5M ops/s +1075%
typeOf<PaymentMethod>18 ns54.4M ops/s +1048%
typeOf<User[]>2.0 µs510K ops/s no change
typeOf<Map<string, User>>2.2 µs446K ops/s no change
reflect(User)187 ns5.3M ops/s no change
reflect(function)186 ns5.4M ops/s no change
resolveReceiveType<string>15 ns65.5M ops/s +5986%
resolveReceiveType<User>305 ns3.3M ops/s +113%
getProperties()0.7 ns1347M ops/s no change
getPropertyNames()0.7 ns1357M ops/s no change
getProperty(name)21 ns47.9M ops/s no change
hasProperty(name)25 ns39.7M ops/s no change
iterate all properties43 ns23.0M ops/s no change
getMethods()0.7 ns1357M ops/s no change
getMethodNames()0.7 ns1357M ops/s no change
getMethod(name)16 ns62.7M ops/s no change
hasMethod(name)21 ns47.3M ops/s no change
method.getParameters()24 ns41.8M ops/s no change
type.kind === ReflectionKind.string3.4 ns297M ops/s no change
type.kind === ReflectionKind.class3.4 ns297M ops/s no change
type.kind === ReflectionKind.union3.4 ns298M ops/s no change
type.kind === ReflectionKind.array3.4 ns297M ops/s no change
property.isOptional()0.7 ns1357M ops/s no change
property.getType()0.7 ns1356M ops/s no change
property.isArray()3.4 ns297M ops/s no change
property.getKind()0.9 ns1056M ops/s no change
ReflectionFunction.from(fn)293 ns3.4M ops/s no change
function.getParameters()0.7 ns1351M ops/s no change
function.getReturnType()0.7 ns1357M ops/s no change
reflection.getClassName()4.2 ns238M ops/s no change
reflection.getClassType()3.8 ns265M ops/s no change
reflection.getConstructorOrUndefined()9.7 ns104M ops/s no change
Serialization24 benchmarks · packages/type/benchmarks/serialization.bench.ts
deepkit small deserialize523 ns1.9M ops/s +97%
deepkit small serialize522 ns1.9M ops/s +98%
deepkit medium deserialize1.1 µs903K ops/s no change
deepkit medium serialize2.6 µs381K ops/s +20%
deepkit large deserialize5.5 µs182K ops/s no change
deepkit large serialize14 µs74.0K ops/s no change
deepkit array[100] deserialize9.0 µs111K ops/s +1480%
deepkit array[100] serialize9.3 µs108K ops/s +1075%
deepkit array[1000] deserialize95 µs10.6K ops/s +187%
deepkit array[1000] serialize96 µs10.4K ops/s +168%
deepkit array[10000] deserialize2.0 ms500 ops/s no change
deepkit array[10000] serialize1.1 ms918 ops/s +53%
deepkit deeply-nested deserialize1.0 µs964K ops/s +52%
deepkit deeply-nested serialize2.2 µs457K ops/s +30%
deepkit union-types deserialize1.2 µs832K ops/s +56%
deepkit union-types serialize1.3 µs749K ops/s no change
deepkit special-types deserialize4.0 µs251K ops/s no change
deepkit special-types serialize9.2 µs109K ops/s no change
deepkit tree-structure deserialize1.3 µs771K ops/s +61%
deepkit tree-structure serialize1.3 µs750K ops/s +54%
deepkit linked-list deserialize723 ns1.4M ops/s +85%
deepkit linked-list serialize679 ns1.5M ops/s +83%
deepkit category-hierarchy deserialize1.2 µs815K ops/s +58%
deepkit category-hierarchy serialize1.3 µs797K ops/s no change
Unions3 benchmarks · packages/type/benchmarks/union.bench.ts
guard union (rotating members)51 ns19.5M ops/s +719%
guard union text only44 ns22.7M ops/s no change
deserialize union284 ns3.5M ops/s no change
Validation33 benchmarks · packages/type/benchmarks/validation.bench.ts
guard (valid)35 ns28.5M ops/s +116%
guard (invalid)40 ns24.8M ops/s +301%
validate (valid)38 ns26.2M ops/s +92%
validate (invalid)141 ns7.1M ops/s no change
is (valid, no errors)61 ns16.3M ops/s +502%
is (invalid, no errors)71 ns14.1M ops/s +626%
is (valid, with errors)73 ns13.8M ops/s +448%
is (invalid, with errors)152 ns6.6M ops/s +338%
assert (valid)85 ns11.8M ops/s +355%
assert (invalid, try-catch)7.1 µs142K ops/s no change
constraints (valid)236 ns4.2M ops/s +14%
constraints (invalid)395 ns2.5M ops/s +93%
constraints validate (invalid)818 ns1.2M ops/s no change
array objects (valid)119 ns8.4M ops/s +127%
array objects (invalid)330 ns3.0M ops/s +407%
array objects validate (invalid)1.6 µs623K ops/s no change
large array (100 items)3.2 µs308K ops/s +99%
deep nested (valid)719 ns1.4M ops/s +68%
deep nested (invalid)931 ns1.1M ops/s +265%
deep nested validate (invalid)2.9 µs346K ops/s no change
union text (valid)25 ns39.5M ops/s +81%
union image (valid)31 ns32.8M ops/s +639%
union video (valid)32 ns31.7M ops/s +1376%
union file (valid)33 ns30.5M ops/s +2276%
union text (invalid)116 ns8.6M ops/s +1142%
union image (invalid)124 ns8.1M ops/s +795%
union validate (invalid)643 ns1.6M ops/s +124%
overhead: guard (valid)35 ns28.3M ops/s +107%
overhead: validate (valid)42 ns23.9M ops/s no change
overhead: guard (invalid)45 ns22.3M ops/s +290%
overhead: validate (invalid)128 ns7.8M ops/s no change
overhead: guard (many errors)371 ns2.7M ops/s +102%
overhead: validate (many errors)869 ns1.2M ops/s no change

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