File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { execute } from 'graphql/execution/execute.js' ;
2
+ import { parse } from 'graphql/language/parser.js' ;
3
+ import { buildSchema } from 'graphql/utilities/buildASTSchema.js' ;
4
+
5
+ const schema = buildSchema ( 'type Query { listField: [String] }' ) ;
6
+ const document = parse ( '{ listField }' ) ;
7
+
8
+ function listField ( ) {
9
+ const results = [ ] ;
10
+ for ( let index = 0 ; index < 1000 ; index ++ ) {
11
+ results . push ( Promise . resolve ( index ) ) ;
12
+ }
13
+ return results ;
14
+ }
15
+
16
+ export const benchmark = {
17
+ name : 'Execute Asynchronous List Field' ,
18
+ count : 10 ,
19
+ async measure ( ) {
20
+ await execute ( {
21
+ schema,
22
+ document,
23
+ rootValue : { listField } ,
24
+ } ) ;
25
+ } ,
26
+ } ;
Original file line number Diff line number Diff line change
1
+ import { execute } from 'graphql/execution/execute.js' ;
2
+ import { parse } from 'graphql/language/parser.js' ;
3
+ import { buildSchema } from 'graphql/utilities/buildASTSchema.js' ;
4
+
5
+ const schema = buildSchema ( 'type Query { listField: [String] }' ) ;
6
+ const document = parse ( '{ listField }' ) ;
7
+
8
+ function listField ( ) {
9
+ const results = [ ] ;
10
+ for ( let index = 0 ; index < 1000 ; index ++ ) {
11
+ results . push ( index ) ;
12
+ }
13
+ return results ;
14
+ }
15
+
16
+ export const benchmark = {
17
+ name : 'Execute Synchronous List Field' ,
18
+ count : 10 ,
19
+ async measure ( ) {
20
+ await execute ( {
21
+ schema,
22
+ document,
23
+ rootValue : { listField } ,
24
+ } ) ;
25
+ } ,
26
+ } ;
You can’t perform that action at this time.
0 commit comments