-
-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "large" benchmarks with "array" and update results
- Loading branch information
1 parent
2b044b3
commit ac6548a
Showing
14 changed files
with
206 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
Core i7 2700K @ 3.5GHz | ||
Windows 10 x64 | ||
10 000 array items | 100 iterations | ||
25 000 array items | 50 iterations | ||
Node.js v13.5 | ||
|
||
----- | ||
Node.js v13.2 | ||
TypeGraphQL | ||
|
||
standard | ||
- 42.551s | ||
- 15.518s | ||
|
||
using sync field resolvers | ||
- 18.180s | ||
|
||
using async field resolvers | ||
- 39.934s | ||
|
||
using getters | ||
- 31.207s | ||
|
||
standard with global middleware | ||
- 62.664s | ||
|
||
with `simpleResolvers: true` | ||
- 11.841s | ||
- 14.980s | ||
|
||
----- | ||
`graphql-js` | ||
|
||
standard | ||
- 13.276s | ||
|
||
graphql-js | ||
- 9.963s | ||
async field resolvers | ||
- 25.630s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
benchmarks/large/tg-async.ts → ...ray/type-graphql/async-field-resolvers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
benchmarks/large/tg-basic.ts → benchmarks/array/type-graphql/standard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
benchmarks/large/tg-sync.ts → ...rray/type-graphql/sync-field-resolvers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import "reflect-metadata"; | ||
import { buildSchema, Field, ObjectType, Resolver, Query, Int } from "../../../build/package/dist"; | ||
|
||
import { runBenchmark, ARRAY_ITEMS } from "../../large/run"; | ||
|
||
@ObjectType() | ||
class SampleObject { | ||
stringField!: string; | ||
@Field({ name: "stringField" }) | ||
get getStringField(): string { | ||
return this.stringField; | ||
} | ||
|
||
numberField!: number; | ||
@Field(type => Int, { name: "numberField" }) | ||
get getNumberField(): number { | ||
return this.numberField; | ||
} | ||
|
||
booleanField!: boolean; | ||
@Field({ name: "booleanField" }) | ||
get getBooleanField(): boolean { | ||
return this.booleanField; | ||
} | ||
|
||
nestedField?: SampleObject; | ||
@Field(type => SampleObject, { name: "nestedField", nullable: true }) | ||
get getNestedField(): SampleObject | undefined { | ||
return this.nestedField; | ||
} | ||
} | ||
|
||
@Resolver(SampleObject) | ||
class SampleResolver { | ||
@Query(returns => [SampleObject]) | ||
multipleNestedObjects(): SampleObject[] { | ||
return Array.from( | ||
{ length: ARRAY_ITEMS }, | ||
(_, index): SampleObject => | ||
({ | ||
stringField: "stringField", | ||
booleanField: true, | ||
numberField: index, | ||
nestedField: { | ||
stringField: "stringField", | ||
booleanField: true, | ||
numberField: index, | ||
} as SampleObject, | ||
} as SampleObject), | ||
); | ||
} | ||
} | ||
|
||
async function main() { | ||
const schema = await buildSchema({ | ||
resolvers: [SampleResolver], | ||
}); | ||
|
||
await runBenchmark(schema); | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import "reflect-metadata"; | ||
import { | ||
buildSchema, | ||
Field, | ||
ObjectType, | ||
Resolver, | ||
Query, | ||
Int, | ||
MiddlewareFn, | ||
} from "../../../build/package/dist"; | ||
|
||
import { runBenchmark, ARRAY_ITEMS } from "../run"; | ||
|
||
@ObjectType() | ||
class SampleObject { | ||
@Field() | ||
stringField!: string; | ||
|
||
@Field(type => Int) | ||
numberField!: number; | ||
|
||
@Field() | ||
booleanField!: boolean; | ||
|
||
@Field({ nullable: true }) | ||
nestedField?: SampleObject; | ||
} | ||
|
||
@Resolver() | ||
class SampleResolver { | ||
@Query(returns => [SampleObject]) | ||
multipleNestedObjects(): SampleObject[] { | ||
return Array.from( | ||
{ length: ARRAY_ITEMS }, | ||
(_, index): SampleObject => ({ | ||
stringField: "stringField", | ||
booleanField: true, | ||
numberField: index, | ||
nestedField: { | ||
stringField: "stringField", | ||
booleanField: true, | ||
numberField: index, | ||
}, | ||
}), | ||
); | ||
} | ||
} | ||
|
||
const log = (...args: any[]) => void 0; // noop | ||
|
||
const loggingMiddleware: MiddlewareFn = ({ info }, next) => { | ||
log(`${info.parentType.name}.${info.fieldName} accessed`); | ||
return next(); | ||
}; | ||
|
||
async function main() { | ||
const schema = await buildSchema({ | ||
resolvers: [SampleResolver], | ||
globalMiddlewares: [loggingMiddleware], | ||
}); | ||
|
||
await runBenchmark(schema); | ||
} | ||
|
||
main().catch(console.error); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.