Mirror: The spec-compliant minimum of client-side GraphQL.

chore: Update benchmarks

Changed files
+103 -10
benchmark
+3 -1
benchmark/package.json
···
},
"dependencies": {
"benchr": "4.3.0",
-
"graphql": "^16.6.0"
+
"graphql15": "npm:graphql@^15.8.0",
+
"graphql16": "npm:graphql@^16.6.0",
+
"graphql17": "npm:graphql@^17.0.0-alpha.2"
}
}
+84 -7
benchmark/suite.js
···
const fs = require('fs');
const graphqlWeb = require('..');
-
const graphql = require('graphql');
+
const graphql15 = require('graphql15');
+
const graphql16 = require('graphql16');
+
const graphql17 = require('graphql17');
-
const kitchenSink = fs.readFileSync('./kitchen_sink.graphql', { encoding: 'utf8' });
-
const document = graphql.parse(kitchenSink, { noLocation: true });
+
const kitchenSink =
+
fs.readFileSync('../src/__tests__/kitchen_sink.graphql', { encoding: 'utf8' });
+
const document = require('../src/__tests__/kitchen_sink.json');
suite('parse kitchen sink query', () => {
benchmark('0no-co/graphql.web', () => {
graphqlWeb.parse(kitchenSink);
});
-
benchmark('graphql', () => {
-
graphql.parse(kitchenSink, { noLocation: true });
+
benchmark('graphql@15', () => {
+
graphql15.parse(kitchenSink, { noLocation: true });
+
});
+
+
benchmark('graphql@16', () => {
+
graphql16.parse(kitchenSink, { noLocation: true });
+
});
+
+
benchmark('graphql@17', () => {
+
graphql17.parse(kitchenSink, { noLocation: true });
});
});
···
graphqlWeb.print(document);
});
-
benchmark('graphql', () => {
-
graphql.print(document);
+
benchmark('graphql@15', () => {
+
graphql15.print(document);
+
});
+
+
benchmark('graphql@16', () => {
+
graphql16.print(document);
+
});
+
+
benchmark('graphql@17', () => {
+
graphql17.print(document);
+
});
+
});
+
+
suite('visit kitchen sink query', () => {
+
benchmark('0no-co/graphql.web', () => {
+
graphqlWeb.visit(document, {
+
Field: formatNode,
+
InlineFragment: formatNode,
+
});
+
});
+
+
benchmark('graphql@15', () => {
+
graphql15.visit(document, {
+
Field: formatNode,
+
InlineFragment: formatNode,
+
});
+
});
+
+
benchmark('graphql@16', () => {
+
graphql16.visit(document, {
+
Field: formatNode,
+
InlineFragment: formatNode,
+
});
+
});
+
+
benchmark('graphql@17', () => {
+
graphql17.visit(document, {
+
Field: formatNode,
+
InlineFragment: formatNode,
+
});
});
});
+
+
function formatNode(node) {
+
if (!node.selectionSet) return node;
+
for (const selection of node.selectionSet.selections)
+
if (
+
selection.kind === 'Field' &&
+
selection.name.value === '__typename' &&
+
!selection.alias
+
)
+
return node;
+
+
return {
+
...node,
+
selectionSet: {
+
...node.selectionSet,
+
selections: [
+
...node.selectionSet.selections,
+
{
+
kind: 'Field',
+
name: {
+
kind: 'Name',
+
value: '__typename',
+
},
+
},
+
],
+
},
+
};
+
}
+16 -2
pnpm-lock.yaml
···
benchmark:
specifiers:
benchr: 4.3.0
-
graphql: ^16.6.0
+
graphql15: npm:graphql@^15.8.0
+
graphql16: npm:graphql@^16.6.0
+
graphql17: npm:graphql@^17.0.0-alpha.2
dependencies:
benchr: 4.3.0
-
graphql: 16.6.0
+
graphql15: /graphql/15.8.0
+
graphql16: /graphql/16.6.0
+
graphql17: /graphql/17.0.0-alpha.2
packages:
···
resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==}
dev: true
+
/graphql/15.8.0:
+
resolution: {integrity: sha512-5gghUc24tP9HRznNpV2+FIoq3xKkj5dTQqf4v0CpdPbFVwFkWoxOM+o+2OC9ZSvjEMTjfmG9QT+gcvggTwW1zw==}
+
engines: {node: '>= 10.x'}
+
dev: false
+
/graphql/16.6.0:
resolution: {integrity: sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==}
engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0}
+
+
/graphql/17.0.0-alpha.2:
+
resolution: {integrity: sha512-aRAd/BQ5hSO0+l7x+sHBfJVUp2JUOjPTE/iwJ3BhtYNH/MC7n4gjlZbKvnBVFZZAczyMS3vezS4teEZivoqIzw==}
+
engines: {node: ^14.19.0 || ^16.10.0 || >=18.0.0}
+
dev: false
/hard-rejection/2.1.0:
resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==}