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.
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
Checks a user object with nested profile and an array of roles. The result is true or false.
The same object with an invalid nested field. The result contains the errors with their path.
JSON-compatible data to a typed object: dates, nested objects, arrays.
A typed object to a JSON string.
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
A row by its primary key.
All rows of the table as objects.
All rows in one call, nothing returned.
Through the ORM, generated primary keys are returned.
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.
A row by its primary key.
All rows of the table as objects.
All rows in one call, nothing returned.
Through the ORM, generated primary keys are returned.
That makes Deepkit ORM the fastest SQLite ORM for TypeScript by a wide margin: ahead of every other ORM in every benchmark.
A row by its primary key.
All rows of the table as objects.
All rows in one call, nothing returned.
Through the ORM, generated primary keys are returned.
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.
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
Two numbers as arguments, one number as result.
A user object as argument and as result.
One number as argument, 100 user objects as result.
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.
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
Two numbers as arguments, one number as result.
A user object as argument and as result.
One number as argument, 100 user objects as result.
64 small calls in flight, one operation is all of them.
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).
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
A user object by its key.
A user object under a key.
A counter under a key.
A user object, until the subscriber received it.
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.19 | 1.1.0 | master | |
|---|---|---|---|
| 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 |
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).
| Codebase | JS plain | JS + types | Size overhead | Gzip overhead | Change | Build plain | Build + types | Build overhead | Change |
|---|---|---|---|---|---|---|---|---|---|
| example-app8 files · 375 lines | 13.2 KB | 17.9 KB | +35.5% | +38.8% | +1.0 points | 1.94 s | 2.07 s | +6.6% | +0.1% |
| http16 files · 4,054 lines | 126.5 KB | 175.1 KB | +38.5% | +48.3% | +0.1 points | 2.01 s | 2.66 s | +32.2% | -4.5% |
| framework29 files · 3,815 lines | 139.5 KB | 181.6 KB | +30.2% | +38.4% | +1.8 points | 2.68 s | 3.40 s | +26.5% | -2.2% |
| type27 files · 12,997 lines | 469.6 KB | 578.2 KB | +23.1% | +30.7% | +0.5 points | 3.42 s | 4.15 s | +21.5% | +0.9% |
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.
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.
| createModule - empty | 29 µs | 34.6K ops/s | -1.5% |
| createModule - with providers | 28 µs | 35.3K ops/s | -1.1% |
| module class instantiation | 1.9 µs | 521K ops/s | +3.2% |
| module class with config | 1.8 µs | 543K ops/s | +6.6% |
| App creation - empty | 1.5 µs | 671K ops/s | -1.7% |
| App creation - with providers | 2.0 µs | 507K ops/s | +5.6% |
| App creation - with imports | 3.8 µs | 266K ops/s | +3.1% |
| App.get() - resolve service | 137 ns | 7.3M ops/s | -7.2% |
| App.get() - from imported module | 47 ns | 21.5M ops/s | -0.0% |
| App.configure() | 2.6 µs | 387K ops/s | +1.8% |
| App creation - nested imports | 5.5 µs | 182K ops/s | +1.4% |
| App.setup() chain | 1.9 µs | 522K ops/s | +0.3% |
| Module.configure() | 2.6 µs | 387K ops/s | +2.9% |
| AppModule direct instantiation | 1.5 µs | 682K ops/s | +0.8% |
| App creation - 5 module imports | 12 µs | 83.3K ops/s | +6.1% |
| serialize small object | 430 ns | 2.3M ops/s | -7.2% |
| deserialize small object | 240 ns | 4.2M ops/s | 1.9× faster |
| serialize object with dates | 559 ns | 1.8M ops/s | 1.2× slower |
| deserialize object with dates | 603 ns | 1.7M ops/s | 1.4× faster |
| serialize nested object | 822 ns | 1.2M ops/s | 1.1× faster |
| deserialize nested object | 691 ns | 1.4M ops/s | 1.5× faster |
| serialize array (1000 items) | 557 µs | 1.8K ops/s | 1.3× faster |
| deserialize array (1000 items) | 483 µs | 2.1K ops/s | 1.7× faster |
| serialize array (5000 items) | 2.8 ms | 359 ops/s | 1.3× faster |
| deserialize array (5000 items) | 2.5 ms | 407 ops/s | 1.9× faster |
| serialize number array (1000) | 45 µs | 22.0K ops/s | 1.4× faster |
| deserialize number array (1000) | 27 µs | 37.6K ops/s | -1.5% |
| serialize string array (1000) | 126 µs | 7.9K ops/s | 4.2× faster |
| deserialize string array (1000) | 221 µs | 4.5K ops/s | 1.2× faster |
| serialize complex document | 2.0 µs | 489K ops/s | 1.5× faster |
| deserialize complex document | 2.8 µs | 359K ops/s | 1.4× faster |
| sync event - single listener | 18 ns | 56.2M ops/s | -3.6% |
| sync event - no listeners | 18 ns | 54.5M ops/s | -2.3% |
| async event - single sync listener | 346 ns | 2.9M ops/s | +1.8% |
| async event - single async listener | 371 ns | 2.7M ops/s | +1.4% |
| async event - 10 listeners | 1.2 µs | 852K ops/s | -0.8% |
| data event - with payload | 448 ns | 2.2M ops/s | +3.5% |
| sync event - pre-compiled dispatcher | 20 ns | 49.1M ops/s | -0.2% |
| sync event - with propagation stop | 81 ns | 12.4M ops/s | -1.0% |
| dispatcher creation + listener add | 430 ns | 2.3M ops/s | -2.2% |
| route match - simple static | 147 ns | 6.8M ops/s | +2.3% |
| route match - single param | 210 ns | 4.8M ops/s | +0.1% |
| route match - multi param | 273 ns | 3.7M ops/s | +1.7% |
| route match - with query | 1.1 µs | 886K ops/s | +0.7% |
| route match - many routes (first) | 66 ns | 15.1M ops/s | +1.8% |
| route match - many routes (middle) | 132 ns | 7.6M ops/s | -2.8% |
| route match - many routes (last) | 379 ns | 2.6M ops/s | -6.4% |
| route match - not found | 213 ns | 4.7M ops/s | -1.7% |
| resolve request - simple | 45 ns | 22.2M ops/s | +1.6% |
| resolve request - with params | 192 ns | 5.2M ops/s | 1.3× faster |
| resolve request - with query | 1.1 µs | 892K ops/s | +1.2% |
| serialize - single user | 1.6 µs | 615K ops/s | -0.8% |
| serialize - user array (10) | 16 µs | 62.2K ops/s | +0.5% |
| serialize - api response | 18 µs | 55.3K ops/s | +0.8% |
| JSON.stringify - single user | 2.9 µs | 340K ops/s | +0.1% |
| JSON.stringify - user array (10) | 23 µs | 44.0K ops/s | -0.0% |
| deserialize - single user | 458 ns | 2.2M ops/s | -0.0% |
| deserialize - user array (10) | 4.6 µs | 219K ops/s | -4.4% |
| JSON.parse - single user | 800 ns | 1.2M ops/s | -0.0% |
| create router registry | 11 ns | 91.8M ops/s | 1.2× faster |
| registry - add GET route | 306 ns | 3.3M ops/s | +1.2% |
| registry - add 5 routes | 1.3 µs | 782K ops/s | +0.9% |
| resolveUrl - single param | 5.6 ns | 179M ops/s | -2.1% |
| resolveUrl - multi param | 9.1 ns | 110M ops/s | -0.9% |
| middleware config - create | 7.5 µs | 134K ops/s | -0.3% |
| middleware config - with route filter | 15 µs | 68.2K ops/s | +1.2% |
| read controller metadata | 38 ns | 26.1M ops/s | 1.1× faster |
| get routes from router | 0.8 ns | 1296M ops/s | -4.5% |
| GET with route parameter | 120 µs | 8.3K ops/s | -2.2% |
| GET list of 10 with query parameter | 159 µs | 6.3K ops/s | -2.0% |
| POST with validated JSON body | 233 µs | 4.3K ops/s | -3.0% |
| validation error (400) | 116 µs | 8.6K ops/s | -3.6% |
| not found (404) | 84 µs | 11.9K ops/s | -5.0% |
| baseline: new Database() | 0.7 ns | 1348M ops/s | +0.3% |
| get simple provider | 22 ns | 46.4M ops/s | -0.0% |
| get provider with dependencies | 22 ns | 46.2M ops/s | -0.0% |
| get via resolver function | 0.7 ns | 1362M ops/s | +0.0% |
| scoped: same scope (cached) | 39 ns | 25.7M ops/s | +1.7% |
| scoped: new scope each call | 54 ns | 18.5M ops/s | -1.1% |
| context.getInjector().get() | 24 ns | 41.4M ops/s | -3.2% |
| new InjectorContext(module) | 2.1 ns | 467M ops/s | -0.0% |
| createChildScope() | 2.2 ns | 460M ops/s | -3.4% |
| createChildScope().getInjector() | 14 ns | 69.8M ops/s | -0.5% |
| 10 providers: get() | 9.7 ns | 104M ops/s | +0.0% |
| 10 providers: resolver() | 0.8 ns | 1297M ops/s | -3.6% |
| 50 providers: get() | 9.7 ns | 103M ops/s | -0.5% |
| 50 providers: resolver() | 0.7 ns | 1334M ops/s | -0.3% |
| 100 providers: get() | 9.7 ns | 104M ops/s | +0.0% |
| 100 providers: resolver() | 0.7 ns | 1338M ops/s | 1.3× faster |
| 200 providers: get() | 9.7 ns | 104M ops/s | -0.0% |
| 200 providers: resolver() | 0.7 ns | 1338M ops/s | +0.2% |
| 500 providers: get() | 9.7 ns | 104M ops/s | +0.1% |
| 500 providers: resolver() | 0.7 ns | 1339M ops/s | +0.6% |
| chain depth 1: get() | 9.7 ns | 104M ops/s | +0.1% |
| chain depth 3: get() | 9.7 ns | 104M ops/s | +0.1% |
| chain depth 5: get() | 9.7 ns | 104M ops/s | +0.1% |
| chain depth 10: get() | 9.7 ns | 103M ops/s | -0.4% |
| singleton: get() | 22 ns | 46.4M ops/s | +0.1% |
| scoped: same scope get() | 43 ns | 23.4M ops/s | -0.6% |
| scoped: new scope + get() | 139 ns | 7.2M ops/s | +1.7% |
| tag injection: get service with tags | 9.7 ns | 104M ops/s | +0.1% |
| transient: get() (new instance) | 55 ns | 18.2M ops/s | +2.3% |
| non-transient: get() (cached) | 22 ns | 46.2M ops/s | +0.7% |
| resolver caching: direct get() | 9.7 ns | 104M ops/s | +0.1% |
| resolver caching: cached resolver() | 0.7 ns | 1347M ops/s | -1.0% |
| resolver caching: context.resolve() | 0.7 ns | 1345M ops/s | -1.1% |
| injector creation: 10 providers | 146 µs | 6.9K ops/s | +1.2% |
| injector creation: 100 providers | 7.7 ms | 131 ops/s | +0.2% |
| injector creation: 500 providers | 83 ms | 12.0 ops/s | +0.6% |
| log info - no formatter | 229 ns | 4.4M ops/s | 1.1× faster |
| log info - default formatter | 2.7 µs | 373K ops/s | +0.9% |
| log info - color formatter | 1.4 µs | 721K ops/s | +2.3% |
| log debug level | 248 ns | 4.0M ops/s | +0.5% |
| log warning level | 249 ns | 4.0M ops/s | +0.4% |
| log error level | 250 ns | 4.0M ops/s | +0.1% |
| log info - disabled (filtered) | 22 ns | 45.8M ops/s | +0.4% |
| scoped logger - info | 1.4 µs | 700K ops/s | +1.5% |
| scoped logger creation (cached) | 0.7 ns | 1361M ops/s | +2.0% |
| log with format args | 685 ns | 1.5M ops/s | +4.8% |
| log with data | 359 ns | 2.8M ops/s | +2.4% |
| memory logger - info | 582 ns | 1.7M ops/s | +0.2% |
| log info - 3 transports | 657 ns | 1.5M ops/s | 1.4× slower |
| logger.is() check | 5.2 ns | 193M ops/s | -0.4% |
| convert filter (no database) | 1.6 µs | 624K ops/s | +3.2% |
| findOne by _id | 230 µs | 4.4K ops/s | 1.4× faster |
| find 100 with hydration | 882 µs | 1.1K ops/s | 1.4× faster |
| find 100 without hydration (lean) | 859 µs | 1.2K ops/s | 1.4× faster |
| count with filter | 799 µs | 1.3K ops/s | 35.7× faster |
| insert one | 199 µs | 5.0K ops/s | 1.5× faster |
| insert 100 in one session | 1.4 ms | 699 ops/s | 1.4× faster |
| patchOne | 360 µs | 2.8K ops/s | +7.8% |
| change detection + update of a loaded entity | 759 µs | 1.3K ops/s | 1.1× faster |
| deleteMany 1,000 rows | 6.9 ms | 145 ops/s | new |
| simple: ping (no args, string return) | 1.0 µs | 973K ops/s | 10.1× faster |
| simple: echo (string arg, string return) | 1.1 µs | 917K ops/s | 9.0× faster |
| simple: add (2 number args, number return) | 984 ns | 1.0M ops/s | 9.7× faster |
| simple: validateNumber (with validation) | 1.0 µs | 983K ops/s | 9.9× faster |
| user: getUser (entity return) | 2.0 µs | 497K ops/s | 7.7× faster |
| user: createUser (2 string args, entity return) | 2.2 µs | 455K ops/s | 7.7× faster |
| product: getProduct (entity return) | 2.0 µs | 502K ops/s | 10.3× faster |
| product: createProduct (complex args, entity return) | 3.3 µs | 302K ops/s | 5.9× faster |
| user: listUsers (complex result with array) | 10.0 µs | 100K ops/s | 3.9× faster |
| product: search (object args, array return) | 11 µs | 88.6K ops/s | 4.1× faster |
| user: processUsers (2 items) | 2.7 µs | 365K ops/s | 6.5× faster |
| user: processUsers (10 items) | 8.2 µs | 122K ops/s | 4.5× faster |
| user: processUsers (100 items) | 70 µs | 14.3K ops/s | 3.2× faster |
| product: bulkCreate (2 items) | 3.2 µs | 314K ops/s | 6.9× faster |
| product: bulkCreate (10 items) | 10 µs | 96.5K ops/s | 4.2× faster |
| type cache: first call (cold) | 642 µs | 1.6K ops/s | 1.5× slower |
| type cache: subsequent calls (warm) | 1.1 µs | 924K ops/s | 8.8× faster |
| sequential: 5 simple calls | 4.5 µs | 220K ops/s | 10.3× faster |
| sequential: 5 entity calls | 9.7 µs | 104K ops/s | 8.2× faster |
| connect + call + disconnect | 584 µs | 1.7K ops/s | 1.3× slower |
| deserialize single entity | 771 ns | 1.3M ops/s | +2.5% |
| deserialize 100 entities | 79 µs | 12.7K ops/s | -0.5% |
| cast single entity | 1.2 µs | 846K ops/s | +1.6% |
| serialize single entity | 2.0 µs | 501K ops/s | +1.4% |
| create query | 359 ns | 2.8M ops/s | 2.8× faster |
| query with filter | 448 ns | 2.2M ops/s | 4.9× faster |
| query with multiple filters | 1.0 µs | 980K ops/s | 6.0× faster |
| query with select | 672 ns | 1.5M ops/s | 3.6× faster |
| clone query | 109 ns | 9.1M ops/s | 10.8× faster |
| create session | 98 ns | 10.2M ops/s | 1.7× faster |
| session add item | 780 ns | 1.3M ops/s | -3.9% |
| session add 10 items | 3.8 µs | 261K ops/s | 1.4× faster |
| query count | 4.0 µs | 251K ops/s | 4.2× faster |
| query findOne | 12 µs | 81.3K ops/s | 5.2× faster |
| query find (limit 10) | 40 µs | 24.7K ops/s | 2.2× faster |
| query find with filter | 41 µs | 24.2K ops/s | 2.5× faster |
| insert single item | 52 µs | 19.4K ops/s | 1.3× faster |
| patch single item | 218 µs | 4.6K ops/s | +7.8% |
| createSnapshot (small entity) | 8.4 ns | 119M ops/s | -0.0% |
| createSnapshot (medium entity) | 3.6 µs | 277K ops/s | +3.2% |
| createSnapshot (large entity) | 5.9 µs | 168K ops/s | +6.3% |
| detect changes (no changes, small) | 36 ns | 28.1M ops/s | -0.5% |
| detect changes (no changes, medium) | 317 ns | 3.2M ops/s | -0.5% |
| detect changes (no changes, large) | 933 ns | 1.1M ops/s | +5.5% |
| detect changes (with changes, small) | 175 ns | 5.7M ops/s | +0.1% |
| detect changes (with changes, medium) | 545 ns | 1.8M ops/s | -0.7% |
| detect changes (with changes, large) | 1.6 µs | 641K ops/s | -0.7% |
| extract primary key (small) | 1.6 ns | 632M ops/s | -0.1% |
| extract primary key (medium) | 1.7 ns | 594M ops/s | -1.0% |
| extract primary key (large) | 28 ns | 36.0M ops/s | -2.3% |
| generate PK hash (small) | 5.0 ns | 199M ops/s | +0.5% |
| generate PK hash (medium) | 5.1 ns | 197M ops/s | -0.0% |
| generate PK hash (large) | 28 ns | 35.8M ops/s | -1.8% |
| buildChanges (no changes, small) | 207 ns | 4.8M ops/s | +1.3% |
| buildChanges (no changes, medium) | 4.2 µs | 238K ops/s | +2.5% |
| buildChanges (no changes, large) | 7.7 µs | 130K ops/s | +4.2% |
| buildChanges (with changes, small) | 280 ns | 3.6M ops/s | 1.1× faster |
| buildChanges (with changes, medium) | 4.4 µs | 227K ops/s | +2.7% |
| buildChanges (with changes, large) | 8.3 µs | 121K ops/s | +4.9% |
| ReflectionClass.from (cached) | 73 ns | 13.7M ops/s | -0.9% |
| typeOf<string> | 788 ns | 1.3M ops/s | +1.0% |
| typeOf<number> | 820 ns | 1.2M ops/s | -0.2% |
| typeOf<User> | 290 ns | 3.5M ops/s | -0.8% |
| typeOf<Product> | 21 ns | 47.3M ops/s | 2.7× slower |
| typeOf<Order> | 21 ns | 47.2M ops/s | -0.5% |
| typeOf<PaymentMethod> | 21 ns | 47.2M ops/s | -4.9% |
| typeOf<User[]> | 2.1 µs | 467K ops/s | -4.4% |
| typeOf<Map<string, User>> | 2.4 µs | 417K ops/s | +4.7% |
| reflect(User) | 189 ns | 5.3M ops/s | -2.1% |
| reflect(function) | 184 ns | 5.4M ops/s | +0.6% |
| resolveReceiveType<string> | 8.8 ns | 113M ops/s | 1.7× faster |
| resolveReceiveType<User> | 301 ns | 3.3M ops/s | -0.7% |
| getProperties() | 0.7 ns | 1356M ops/s | +0.0% |
| getPropertyNames() | 0.7 ns | 1357M ops/s | +0.1% |
| getProperty(name) | 20 ns | 49.5M ops/s | +1.4% |
| hasProperty(name) | 25 ns | 39.3M ops/s | -0.9% |
| iterate all properties | 43 ns | 23.0M ops/s | -0.0% |
| getMethods() | 0.7 ns | 1357M ops/s | -0.0% |
| getMethodNames() | 0.7 ns | 1357M ops/s | -0.0% |
| getMethod(name) | 16 ns | 62.6M ops/s | -0.0% |
| hasMethod(name) | 21 ns | 47.1M ops/s | +0.7% |
| method.getParameters() | 24 ns | 41.8M ops/s | -0.0% |
| type.kind === ReflectionKind.string | 3.4 ns | 297M ops/s | -0.0% |
| type.kind === ReflectionKind.class | 3.4 ns | 297M ops/s | -0.0% |
| type.kind === ReflectionKind.union | 3.4 ns | 297M ops/s | -0.0% |
| type.kind === ReflectionKind.array | 3.4 ns | 297M ops/s | -0.0% |
| property.isOptional() | 0.7 ns | 1357M ops/s | +0.0% |
| property.getType() | 0.7 ns | 1357M ops/s | +0.1% |
| property.isArray() | 3.4 ns | 297M ops/s | +0.0% |
| property.getKind() | 0.9 ns | 1056M ops/s | +0.0% |
| ReflectionFunction.from(fn) | 290 ns | 3.4M ops/s | +0.2% |
| function.getParameters() | 0.7 ns | 1351M ops/s | -0.0% |
| function.getReturnType() | 0.7 ns | 1357M ops/s | +0.0% |
| reflection.getClassName() | 4.2 ns | 238M ops/s | -0.0% |
| reflection.getClassType() | 3.8 ns | 264M ops/s | +0.0% |
| reflection.getConstructorOrUndefined() | 9.6 ns | 104M ops/s | +0.0% |
| deepkit small deserialize | 467 ns | 2.1M ops/s | 1.1× faster |
| deepkit small serialize | 477 ns | 2.1M ops/s | 1.1× faster |
| deepkit medium deserialize | 863 ns | 1.2M ops/s | 1.3× faster |
| deepkit medium serialize | 2.4 µs | 418K ops/s | 1.1× faster |
| deepkit large deserialize | 5.1 µs | 197K ops/s | +6.3% |
| deepkit large serialize | 13 µs | 79.9K ops/s | +9.8% |
| deepkit array[100] deserialize | 7.3 µs | 138K ops/s | 1.2× faster |
| deepkit array[100] serialize | 7.4 µs | 135K ops/s | 1.3× faster |
| deepkit array[1000] deserialize | 75 µs | 13.4K ops/s | 1.3× faster |
| deepkit array[1000] serialize | 77 µs | 13.0K ops/s | 1.3× faster |
| deepkit array[10000] deserialize | 1.7 ms | 593 ops/s | 1.2× faster |
| deepkit array[10000] serialize | 810 µs | 1.2K ops/s | 1.4× faster |
| deepkit deeply-nested deserialize | 940 ns | 1.1M ops/s | 1.1× faster |
| deepkit deeply-nested serialize | 2.1 µs | 478K ops/s | +6.0% |
| deepkit union-types deserialize | 930 ns | 1.1M ops/s | 1.3× faster |
| deepkit union-types serialize | 1.1 µs | 952K ops/s | 1.3× faster |
| deepkit special-types deserialize | 4.0 µs | 250K ops/s | -0.4% |
| deepkit special-types serialize | 9.0 µs | 111K ops/s | +1.5% |
| deepkit tree-structure deserialize | 1.2 µs | 861K ops/s | 1.1× faster |
| deepkit tree-structure serialize | 1.1 µs | 889K ops/s | 1.2× faster |
| deepkit linked-list deserialize | 675 ns | 1.5M ops/s | +7.2% |
| deepkit linked-list serialize | 646 ns | 1.5M ops/s | +5.9% |
| deepkit category-hierarchy deserialize | 1.2 µs | 852K ops/s | 1.1× faster |
| deepkit category-hierarchy serialize | 1.2 µs | 865K ops/s | +7.7% |
| guard union (rotating members) | 51 ns | 19.5M ops/s | -0.4% |
| guard union text only | 44 ns | 22.6M ops/s | +0.4% |
| deserialize union | 288 ns | 3.5M ops/s | -0.9% |
| guard (valid) | 35 ns | 28.4M ops/s | -0.8% |
| guard (invalid) | 41 ns | 24.4M ops/s | +0.2% |
| validate (valid) | 37 ns | 26.9M ops/s | +3.0% |
| validate (invalid) | 140 ns | 7.1M ops/s | -0.1% |
| is (valid, no errors) | 61 ns | 16.5M ops/s | +3.6% |
| is (invalid, no errors) | 72 ns | 13.8M ops/s | -0.3% |
| is (valid, with errors) | 70 ns | 14.3M ops/s | +0.5% |
| is (invalid, with errors) | 158 ns | 6.3M ops/s | -3.6% |
| assert (valid) | 83 ns | 12.1M ops/s | +1.9% |
| assert (invalid, try-catch) | 6.8 µs | 146K ops/s | +1.3% |
| constraints (valid) | 241 ns | 4.2M ops/s | -0.8% |
| constraints (invalid) | 395 ns | 2.5M ops/s | -0.4% |
| constraints validate (invalid) | 821 ns | 1.2M ops/s | +0.0% |
| array objects (valid) | 121 ns | 8.3M ops/s | -0.7% |
| array objects (invalid) | 328 ns | 3.0M ops/s | +1.5% |
| array objects validate (invalid) | 1.6 µs | 622K ops/s | -0.5% |
| large array (100 items) | 3.2 µs | 309K ops/s | +0.3% |
| deep nested (valid) | 717 ns | 1.4M ops/s | +1.3% |
| deep nested (invalid) | 932 ns | 1.1M ops/s | +0.2% |
| deep nested validate (invalid) | 2.9 µs | 348K ops/s | 1.2× faster |
| union text (valid) | 25 ns | 39.5M ops/s | 1.2× faster |
| union image (valid) | 31 ns | 32.0M ops/s | -1.1% |
| union video (valid) | 30 ns | 33.4M ops/s | -0.9% |
| union file (valid) | 32 ns | 30.9M ops/s | -1.0% |
| union text (invalid) | 116 ns | 8.6M ops/s | +0.1% |
| union image (invalid) | 125 ns | 8.0M ops/s | +0.3% |
| union validate (invalid) | 644 ns | 1.6M ops/s | -0.1% |
| overhead: guard (valid) | 37 ns | 27.4M ops/s | -2.0% |
| overhead: validate (valid) | 41 ns | 24.2M ops/s | +0.7% |
| overhead: guard (invalid) | 45 ns | 22.3M ops/s | -1.5% |
| overhead: validate (invalid) | 124 ns | 8.1M ops/s | +0.8% |
| overhead: guard (many errors) | 362 ns | 2.8M ops/s | -0.1% |
| overhead: validate (many errors) | 870 ns | 1.1M ops/s | +0.0% |
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