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