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 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.
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,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.
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 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.
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 6.2 µs, 5.6x faster than over a unix socket (34.5 µs) and 7.0x faster than over TCP (43.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 71, slower in 1 and unchanged within the measurement error in 300 of 372 benchmarks.
| 1.0.18 | 1.1.0 | master | |
|---|---|---|---|
| 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 |
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.91 s | 2.06 s | +7.9% | -0.4% |
| http16 files · 4,054 lines | 126.5 KB | 175.1 KB | +38.5% | +48.3% | +0.1 points | 2.00 s | 2.65 s | +32.5% | -5.0% |
| framework29 files · 3,815 lines | 139.5 KB | 181.6 KB | +30.2% | +38.4% | +1.8 points | 2.68 s | 3.41 s | +26.9% | -1.9% |
| 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.4% | +1.0% |
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 | 35.0K ops/s | -0.4% |
| createModule - with providers | 28 µs | 35.7K ops/s | -0.1% |
| module class instantiation | 1.8 µs | 550K ops/s | +8.9% |
| module class with config | 1.8 µs | 547K ops/s | +7.3% |
| App creation - empty | 1.5 µs | 680K ops/s | -0.3% |
| App creation - with providers | 2.0 µs | 492K ops/s | +2.6% |
| App creation - with imports | 3.8 µs | 263K ops/s | +2.3% |
| App.get() - resolve service | 136 ns | 7.3M ops/s | -6.6% |
| App.get() - from imported module | 47 ns | 21.4M ops/s | -0.5% |
| App.configure() | 2.5 µs | 401K ops/s | +5.5% |
| App creation - nested imports | 5.5 µs | 183K ops/s | +1.8% |
| App.setup() chain | 2.0 µs | 502K ops/s | -3.5% |
| Module.configure() | 2.6 µs | 389K ops/s | +3.4% |
| AppModule direct instantiation | 1.5 µs | 663K ops/s | -2.0% |
| App creation - 5 module imports | 12 µs | 83.5K ops/s | +6.3% |
| serialize small object | 426 ns | 2.3M ops/s | -6.3% |
| deserialize small object | 254 ns | 3.9M ops/s | 1.8× faster |
| serialize object with dates | 560 ns | 1.8M ops/s | 1.2× slower |
| deserialize object with dates | 608 ns | 1.6M ops/s | 1.4× faster |
| serialize nested object | 820 ns | 1.2M ops/s | 1.2× faster |
| deserialize nested object | 688 ns | 1.5M ops/s | 1.5× faster |
| serialize array (1000 items) | 554 µs | 1.8K ops/s | 1.3× faster |
| deserialize array (1000 items) | 480 µs | 2.1K ops/s | 1.7× faster |
| serialize array (5000 items) | 2.8 ms | 361 ops/s | 1.3× faster |
| deserialize array (5000 items) | 2.4 ms | 416 ops/s | 2.0× faster |
| serialize number array (1000) | 45 µs | 22.2K ops/s | 1.4× faster |
| deserialize number array (1000) | 27 µs | 37.7K ops/s | -1.1% |
| serialize string array (1000) | 124 µs | 8.1K ops/s | 4.3× faster |
| deserialize string array (1000) | 155 µs | 6.5K ops/s | 1.8× faster |
| serialize complex document | 2.0 µs | 500K ops/s | 1.6× faster |
| deserialize complex document | 2.8 µs | 360K ops/s | 1.4× faster |
| sync event - single listener | 18 ns | 56.4M ops/s | -3.2% |
| sync event - no listeners | 19 ns | 53.3M ops/s | -4.5% |
| async event - single sync listener | 355 ns | 2.8M ops/s | -0.8% |
| async event - single async listener | 375 ns | 2.7M ops/s | +0.4% |
| async event - 10 listeners | 1.2 µs | 869K ops/s | +1.3% |
| data event - with payload | 451 ns | 2.2M ops/s | +2.8% |
| sync event - pre-compiled dispatcher | 20 ns | 49.0M ops/s | -0.4% |
| sync event - with propagation stop | 80 ns | 12.5M ops/s | +0.2% |
| dispatcher creation + listener add | 420 ns | 2.4M ops/s | +0.0% |
| route match - simple static | 149 ns | 6.7M ops/s | +0.9% |
| route match - single param | 208 ns | 4.8M ops/s | +1.1% |
| route match - multi param | 278 ns | 3.6M ops/s | -0.1% |
| route match - with query | 1.1 µs | 883K ops/s | +0.4% |
| route match - many routes (first) | 69 ns | 14.5M ops/s | -2.2% |
| route match - many routes (middle) | 130 ns | 7.7M ops/s | -1.8% |
| route match - many routes (last) | 353 ns | 2.8M ops/s | +0.6% |
| route match - not found | 208 ns | 4.8M ops/s | +0.8% |
| resolve request - simple | 43 ns | 23.0M ops/s | +5.5% |
| resolve request - with params | 185 ns | 5.4M ops/s | 1.3× faster |
| resolve request - with query | 1.1 µs | 896K ops/s | +1.7% |
| serialize - single user | 1.6 µs | 627K ops/s | +1.1% |
| serialize - user array (10) | 16 µs | 62.7K ops/s | +1.2% |
| serialize - api response | 18 µs | 55.8K ops/s | +1.7% |
| JSON.stringify - single user | 3.0 µs | 335K ops/s | -1.4% |
| JSON.stringify - user array (10) | 23 µs | 43.2K ops/s | -1.7% |
| deserialize - single user | 463 ns | 2.2M ops/s | -1.1% |
| deserialize - user array (10) | 4.6 µs | 218K ops/s | -4.9% |
| JSON.parse - single user | 798 ns | 1.3M ops/s | +0.3% |
| create router registry | 12 ns | 84.6M ops/s | 1.1× faster |
| registry - add GET route | 310 ns | 3.2M ops/s | -0.3% |
| registry - add 5 routes | 1.3 µs | 773K ops/s | -0.3% |
| resolveUrl - single param | 5.5 ns | 183M ops/s | +0.0% |
| resolveUrl - multi param | 8.9 ns | 112M ops/s | +0.9% |
| middleware config - create | 7.5 µs | 133K ops/s | -1.1% |
| middleware config - with route filter | 15 µs | 67.7K ops/s | +0.4% |
| read controller metadata | 39 ns | 25.5M ops/s | 1.1× faster |
| get routes from router | 0.7 ns | 1357M ops/s | +0.0% |
| baseline: new Database() | 0.7 ns | 1345M ops/s | +0.0% |
| get simple provider | 23 ns | 43.1M ops/s | -7.1% |
| get provider with dependencies | 22 ns | 46.4M ops/s | +0.3% |
| get via resolver function | 0.7 ns | 1362M ops/s | +0.0% |
| scoped: same scope (cached) | 39 ns | 25.9M ops/s | +2.8% |
| scoped: new scope each call | 54 ns | 18.6M ops/s | -0.3% |
| 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.5% |
| createChildScope().getInjector() | 15 ns | 67.8M ops/s | -3.3% |
| 10 providers: get() | 9.7 ns | 104M ops/s | -0.0% |
| 10 providers: resolver() | 0.7 ns | 1361M ops/s | +1.2% |
| 50 providers: get() | 9.7 ns | 104M ops/s | +0.0% |
| 50 providers: resolver() | 0.7 ns | 1339M ops/s | +0.0% |
| 100 providers: get() | 9.7 ns | 104M ops/s | +0.0% |
| 100 providers: resolver() | 0.7 ns | 1339M ops/s | 1.3× faster |
| 200 providers: get() | 9.6 ns | 104M ops/s | +0.0% |
| 200 providers: resolver() | 0.7 ns | 1339M ops/s | +0.2% |
| 500 providers: get() | 9.7 ns | 104M ops/s | +0.2% |
| 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 | 104M ops/s | +0.1% |
| singleton: get() | 22 ns | 46.2M ops/s | -0.2% |
| scoped: same scope get() | 44 ns | 22.7M ops/s | -3.7% |
| scoped: new scope + get() | 144 ns | 6.9M ops/s | -2.3% |
| tag injection: get service with tags | 9.7 ns | 103M ops/s | -0.4% |
| transient: get() (new instance) | 56 ns | 18.0M ops/s | +1.3% |
| non-transient: get() (cached) | 22 ns | 45.9M ops/s | +0.2% |
| resolver caching: direct get() | 9.7 ns | 104M ops/s | +0.1% |
| resolver caching: cached resolver() | 0.7 ns | 1362M ops/s | +0.1% |
| resolver caching: context.resolve() | 0.7 ns | 1345M ops/s | -1.1% |
| injector creation: 10 providers | 145 µs | 6.9K ops/s | +1.4% |
| injector creation: 100 providers | 7.7 ms | 131 ops/s | +0.3% |
| injector creation: 500 providers | 83 ms | 12.0 ops/s | +1.0% |
| log info - no formatter | 230 ns | 4.3M ops/s | 1.1× faster |
| log info - default formatter | 2.7 µs | 367K ops/s | -0.7% |
| log info - color formatter | 1.4 µs | 716K ops/s | +1.5% |
| log debug level | 243 ns | 4.1M ops/s | +2.7% |
| log warning level | 243 ns | 4.1M ops/s | +2.9% |
| log error level | 243 ns | 4.1M ops/s | +2.9% |
| log info - disabled (filtered) | 23 ns | 43.0M ops/s | -5.7% |
| scoped logger - info | 1.4 µs | 690K ops/s | +0.0% |
| scoped logger creation (cached) | 0.7 ns | 1362M ops/s | +2.1% |
| log with format args | 697 ns | 1.4M ops/s | +3.1% |
| log with data | 359 ns | 2.8M ops/s | +2.4% |
| memory logger - info | 552 ns | 1.8M ops/s | +5.6% |
| log info - 3 transports | 488 ns | 2.0M ops/s | -0.4% |
| logger.is() check | 5.2 ns | 194M ops/s | -0.1% |
| convert filter (no database) | 1.6 µs | 639K ops/s | +5.7% |
| findOne by _id | 213 µs | 4.7K ops/s | 1.5× faster |
| count with filter | 5.8 ms | 173 ops/s | 4.9× faster |
| insert one | 211 µs | 4.7K ops/s | 1.4× faster |
| insert 100 in one session | 1.5 ms | 687 ops/s | 1.4× faster |
| patchOne | 365 µs | 2.7K ops/s | +6.3% |
| change detection + update of a loaded entity | 765 µs | 1.3K ops/s | 1.1× faster |
| deleteMany 1,000 rows | 7.0 ms | 142 ops/s | new |
| simple: ping (no args, string return) | 950 ns | 1.1M ops/s | 11.0× faster |
| simple: echo (string arg, string return) | 1.1 µs | 927K ops/s | 9.1× faster |
| simple: add (2 number args, number return) | 922 ns | 1.1M ops/s | 10.3× faster |
| simple: validateNumber (with validation) | 1.1 µs | 908K ops/s | 9.2× faster |
| user: getUser (entity return) | 2.1 µs | 468K ops/s | 7.2× faster |
| user: createUser (2 string args, entity return) | 2.3 µs | 431K ops/s | 7.3× faster |
| product: getProduct (entity return) | 2.0 µs | 497K ops/s | 10.2× faster |
| product: createProduct (complex args, entity return) | 3.2 µs | 310K ops/s | 6.1× faster |
| user: listUsers (complex result with array) | 10.0 µs | 100K ops/s | 3.9× faster |
| product: search (object args, array return) | 11 µs | 91.5K ops/s | 4.3× faster |
| user: processUsers (2 items) | 2.8 µs | 354K ops/s | 6.3× faster |
| user: processUsers (10 items) | 8.2 µs | 122K ops/s | 4.5× faster |
| user: processUsers (100 items) | 70 µs | 14.2K ops/s | 3.2× faster |
| product: bulkCreate (2 items) | 2.9 µs | 340K ops/s | 7.4× faster |
| product: bulkCreate (10 items) | 10 µs | 96.9K ops/s | 4.2× faster |
| type cache: first call (cold) | 659 µs | 1.5K ops/s | 1.6× slower |
| type cache: subsequent calls (warm) | 952 ns | 1.1M ops/s | 10.0× faster |
| sequential: 5 simple calls | 4.4 µs | 227K ops/s | 10.6× faster |
| sequential: 5 entity calls | 10 µs | 97.8K ops/s | 7.8× faster |
| connect + call + disconnect | 615 µs | 1.6K ops/s | 1.3× slower |
| deserialize single entity | 779 ns | 1.3M ops/s | +1.5% |
| deserialize 100 entities | 79 µs | 12.7K ops/s | -0.4% |
| cast single entity | 1.2 µs | 847K ops/s | +1.7% |
| serialize single entity | 2.0 µs | 492K ops/s | -0.4% |
| create query | 364 ns | 2.7M ops/s | 2.7× faster |
| query with filter | 450 ns | 2.2M ops/s | 4.9× faster |
| query with multiple filters | 1.0 µs | 968K ops/s | 5.9× faster |
| query with select | 730 ns | 1.4M ops/s | 3.4× faster |
| clone query | 111 ns | 9.0M ops/s | 10.6× faster |
| create session | 99 ns | 10.1M ops/s | 1.7× faster |
| session add item | 809 ns | 1.2M ops/s | -7.4% |
| session add 10 items | 4.0 µs | 250K ops/s | 1.3× faster |
| query count | 4.2 µs | 238K ops/s | 4.0× faster |
| query findOne | 12 µs | 85.4K ops/s | 5.4× faster |
| query find (limit 10) | 41 µs | 24.3K ops/s | 2.2× faster |
| query find with filter | 43 µs | 23.4K ops/s | 2.5× faster |
| insert single item | 55 µs | 18.3K ops/s | 1.2× faster |
| patch single item | 221 µs | 4.5K ops/s | +6.4% |
| createSnapshot (small entity) | 8.4 ns | 119M ops/s | +0.0% |
| createSnapshot (medium entity) | 3.6 µs | 274K ops/s | +2.1% |
| createSnapshot (large entity) | 5.9 µs | 169K ops/s | +6.8% |
| detect changes (no changes, small) | 35 ns | 28.2M ops/s | -0.3% |
| detect changes (no changes, medium) | 316 ns | 3.2M ops/s | -0.3% |
| detect changes (no changes, large) | 929 ns | 1.1M ops/s | +5.9% |
| detect changes (with changes, small) | 174 ns | 5.7M ops/s | +0.2% |
| detect changes (with changes, medium) | 538 ns | 1.9M ops/s | +0.6% |
| detect changes (with changes, large) | 1.6 µs | 643K ops/s | -0.3% |
| extract primary key (small) | 1.6 ns | 634M ops/s | +0.1% |
| extract primary key (medium) | 1.7 ns | 604M ops/s | +0.7% |
| extract primary key (large) | 27 ns | 37.3M ops/s | +1.2% |
| 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.9M ops/s | -1.5% |
| buildChanges (no changes, small) | 209 ns | 4.8M ops/s | +0.3% |
| buildChanges (no changes, medium) | 4.3 µs | 235K ops/s | +1.2% |
| buildChanges (no changes, large) | 12 µs | 80.2K ops/s | 1.6× slower |
| buildChanges (with changes, small) | 280 ns | 3.6M ops/s | 1.1× faster |
| buildChanges (with changes, medium) | 4.5 µs | 224K ops/s | +1.2% |
| buildChanges (with changes, large) | 8.7 µs | 115K ops/s | +0.1% |
| ReflectionClass.from (cached) | 73 ns | 13.7M ops/s | -0.9% |
| typeOf<string> | 776 ns | 1.3M ops/s | +2.5% |
| typeOf<number> | 814 ns | 1.2M ops/s | +0.6% |
| typeOf<User> | 281 ns | 3.6M ops/s | +2.2% |
| typeOf<Product> | 7.7 ns | 130M ops/s | +0.4% |
| typeOf<Order> | 18 ns | 54.6M ops/s | 1.1× faster |
| typeOf<PaymentMethod> | 18 ns | 54.5M ops/s | +9.8% |
| typeOf<User[]> | 2.0 µs | 498K ops/s | +2.0% |
| typeOf<Map<string, User>> | 2.3 µs | 437K ops/s | +9.6% |
| reflect(User) | 184 ns | 5.4M ops/s | +0.3% |
| reflect(function) | 183 ns | 5.5M ops/s | +1.0% |
| resolveReceiveType<string> | 15 ns | 66.1M ops/s | +0.3% |
| resolveReceiveType<User> | 294 ns | 3.4M ops/s | +1.5% |
| getProperties() | 0.7 ns | 1357M ops/s | +0.1% |
| getPropertyNames() | 0.7 ns | 1357M ops/s | +0.1% |
| getProperty(name) | 21 ns | 46.8M ops/s | -4.0% |
| hasProperty(name) | 25 ns | 39.6M ops/s | -0.1% |
| 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.7M ops/s | +0.0% |
| hasMethod(name) | 21 ns | 46.9M ops/s | +0.0% |
| method.getParameters() | 24 ns | 41.8M ops/s | -0.1% |
| type.kind === ReflectionKind.string | 3.4 ns | 297M ops/s | -0.0% |
| type.kind === ReflectionKind.class | 3.4 ns | 298M ops/s | +0.0% |
| type.kind === ReflectionKind.union | 3.4 ns | 298M ops/s | +0.0% |
| type.kind === ReflectionKind.array | 3.4 ns | 298M ops/s | +0.1% |
| property.isOptional() | 0.7 ns | 1356M 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) | 298 ns | 3.4M ops/s | -2.3% |
| function.getParameters() | 0.7 ns | 1351M ops/s | +0.0% |
| function.getReturnType() | 0.7 ns | 1356M ops/s | -0.0% |
| reflection.getClassName() | 4.2 ns | 238M ops/s | +0.0% |
| reflection.getClassType() | 3.8 ns | 265M ops/s | +0.1% |
| reflection.getConstructorOrUndefined() | 9.6 ns | 104M ops/s | +0.1% |
| deepkit small deserialize | 460 ns | 2.2M ops/s | 1.1× faster |
| deepkit small serialize | 544 ns | 1.8M ops/s | -2.7% |
| deepkit medium deserialize | 870 ns | 1.1M ops/s | 1.3× faster |
| deepkit medium serialize | 2.4 µs | 422K ops/s | 1.1× faster |
| deepkit large deserialize | 5.2 µs | 191K ops/s | +2.8% |
| deepkit large serialize | 12 µs | 80.6K ops/s | 1.1× faster |
| deepkit array[100] deserialize | 7.4 µs | 135K ops/s | 1.2× faster |
| deepkit array[100] serialize | 7.4 µs | 134K ops/s | 1.3× faster |
| deepkit array[1000] deserialize | 161 µs | 6.2K ops/s | 1.7× slower |
| deepkit array[1000] serialize | 78 µs | 12.8K ops/s | 1.2× faster |
| deepkit array[10000] deserialize | 771 µs | 1.3K ops/s | 2.5× faster |
| deepkit array[10000] serialize | 798 µs | 1.3K ops/s | 1.4× faster |
| deepkit deeply-nested deserialize | 941 ns | 1.1M ops/s | 1.1× faster |
| deepkit deeply-nested serialize | 2.1 µs | 476K ops/s | +5.7% |
| deepkit union-types deserialize | 929 ns | 1.1M ops/s | 1.3× faster |
| deepkit union-types serialize | 1.1 µs | 937K ops/s | 1.3× faster |
| deepkit special-types deserialize | 4.0 µs | 249K ops/s | -0.6% |
| deepkit special-types serialize | 9.0 µs | 111K ops/s | +1.9% |
| deepkit tree-structure deserialize | 1.2 µs | 837K ops/s | +8.6% |
| deepkit tree-structure serialize | 1.1 µs | 882K ops/s | 1.2× faster |
| deepkit linked-list deserialize | 679 ns | 1.5M ops/s | +6.7% |
| deepkit linked-list serialize | 649 ns | 1.5M ops/s | +5.3% |
| deepkit category-hierarchy deserialize | 1.2 µs | 852K ops/s | 1.1× faster |
| deepkit category-hierarchy serialize | 1.2 µs | 866K ops/s | +7.8% |
| guard union (rotating members) | 51 ns | 19.6M ops/s | +0.3% |
| guard union text only | 44 ns | 22.7M ops/s | +0.7% |
| deserialize union | 285 ns | 3.5M ops/s | +0.3% |
| guard (valid) | 35 ns | 28.5M ops/s | -0.6% |
| guard (invalid) | 40 ns | 24.7M ops/s | +1.5% |
| validate (valid) | 38 ns | 26.4M ops/s | +0.8% |
| validate (invalid) | 141 ns | 7.1M ops/s | -0.8% |
| is (valid, no errors) | 62 ns | 16.2M ops/s | +1.4% |
| is (invalid, no errors) | 70 ns | 14.4M ops/s | +3.5% |
| is (valid, with errors) | 70 ns | 14.3M ops/s | +0.3% |
| is (invalid, with errors) | 155 ns | 6.4M ops/s | -1.9% |
| assert (valid) | 82 ns | 12.2M ops/s | +2.9% |
| assert (invalid, try-catch) | 6.7 µs | 149K ops/s | +3.2% |
| constraints (valid) | 239 ns | 4.2M ops/s | -0.1% |
| constraints (invalid) | 394 ns | 2.5M ops/s | -0.0% |
| constraints validate (invalid) | 818 ns | 1.2M ops/s | +0.4% |
| array objects (valid) | 119 ns | 8.4M ops/s | +1.3% |
| array objects (invalid) | 328 ns | 3.1M ops/s | +1.6% |
| array objects validate (invalid) | 1.6 µs | 625K ops/s | -0.1% |
| large array (100 items) | 3.2 µs | 310K ops/s | +0.6% |
| deep nested (valid) | 718 ns | 1.4M ops/s | +1.1% |
| deep nested (invalid) | 936 ns | 1.1M ops/s | -0.2% |
| deep nested validate (invalid) | 2.9 µs | 347K ops/s | 1.1× faster |
| union text (valid) | 25 ns | 39.5M ops/s | 1.2× faster |
| union image (valid) | 31 ns | 32.3M ops/s | -0.4% |
| union video (valid) | 30 ns | 33.9M ops/s | +0.4% |
| union file (valid) | 32 ns | 31.0M ops/s | -0.8% |
| union text (invalid) | 116 ns | 8.6M ops/s | +0.2% |
| union image (invalid) | 125 ns | 8.0M ops/s | +0.5% |
| union validate (invalid) | 646 ns | 1.5M ops/s | -0.4% |
| overhead: guard (valid) | 36 ns | 28.1M ops/s | +0.7% |
| overhead: validate (valid) | 42 ns | 23.8M ops/s | -1.0% |
| overhead: guard (invalid) | 44 ns | 22.7M ops/s | +0.1% |
| overhead: validate (invalid) | 127 ns | 7.8M ops/s | -2.0% |
| overhead: guard (many errors) | 377 ns | 2.7M ops/s | -4.1% |
| overhead: validate (many errors) | 1.1 µs | 885K ops/s | 1.3× slower |
| GET with route parameter | 21 µs | 46.9K ops/s | 5.5× faster |
| GET list of 10 with query parameter | 49 µs | 20.5K ops/s | 3.2× faster |
| POST with validated JSON body | 26 µs | 38.0K ops/s | 8.6× faster |
| validation error (400) | 32 µs | 31.3K ops/s | 3.5× faster |
| not found (404) | 12 µs | 81.2K ops/s | 6.5× faster |
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