From 7e793c133f5b9c47a1b12e98ea3a35b1b1471dc4 Mon Sep 17 00:00:00 2001 From: Rob Richard Date: Sun, 4 Oct 2020 10:47:16 -0400 Subject: [PATCH] add benchmark tests for async iterable list fields --- benchmark/list-asyncIterable-benchmark.js | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 benchmark/list-asyncIterable-benchmark.js diff --git a/benchmark/list-asyncIterable-benchmark.js b/benchmark/list-asyncIterable-benchmark.js new file mode 100644 index 0000000000..3863cca833 --- /dev/null +++ b/benchmark/list-asyncIterable-benchmark.js @@ -0,0 +1,26 @@ +'use strict'; + +const { parse } = require('graphql/language/parser.js'); +const { execute } = require('graphql/execution/execute.js'); +const { buildSchema } = require('graphql/utilities/buildASTSchema.js'); + +const schema = buildSchema('type Query { listField: [String] }'); +const document = parse('{ listField }'); + +async function* listField() { + for (let index = 0; index < 100000; index++) { + yield index; + } +} + +module.exports = { + name: 'Execute Async Iterable List Field', + count: 10, + async measure() { + await execute({ + schema, + document, + rootValue: { listField }, + }); + }, +};