Skip to content

Commit d9f43c8

Browse files
authored
internal: use mitata for benchmark timing (#4682)
1 parent 5a36035 commit d9f43c8

25 files changed

Lines changed: 72 additions & 141 deletions

benchmark/GraphQLSchema-benchmark.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,5 @@ const bigSchema = buildClientSchema(bigSchemaIntrospectionResult.data);
77

88
export const benchmark = {
99
name: 'Recreate a GraphQLSchema',
10-
count: 40,
11-
measure() {
12-
// eslint-disable-next-line no-new
13-
new GraphQLSchema(bigSchema.toConfig());
14-
},
10+
measure: () => new GraphQLSchema(bigSchema.toConfig()),
1511
};

benchmark/buildASTSchema-benchmark.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@ const schemaAST = parse(bigSchemaSDL);
77

88
export const benchmark = {
99
name: 'Build Schema from AST',
10-
count: 10,
11-
measure() {
12-
buildASTSchema(schemaAST, { assumeValid: true });
13-
},
10+
measure: () => buildASTSchema(schemaAST, { assumeValid: true }),
1411
};

benchmark/buildClientSchema-benchmark.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { bigSchemaIntrospectionResult } from './fixtures.js';
44

55
export const benchmark = {
66
name: 'Build Schema from Introspection',
7-
count: 10,
8-
measure() {
9-
buildClientSchema(bigSchemaIntrospectionResult.data, { assumeValid: true });
10-
},
7+
measure: () =>
8+
buildClientSchema(bigSchemaIntrospectionResult.data, { assumeValid: true }),
119
};

benchmark/introspectionFromSchema-benchmark.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@ const document = parse(getIntrospectionQuery());
1010

1111
export const benchmark = {
1212
name: 'Execute Introspection Query',
13-
count: 20,
14-
measure() {
15-
executeSync({ schema, document });
16-
},
13+
measure: () => executeSync({ schema, document }),
1714
};

benchmark/list-async-benchmark.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ function listField() {
1515

1616
export const benchmark = {
1717
name: 'Execute Asynchronous List Field',
18-
count: 10,
19-
async measure() {
20-
await execute({
18+
measure: () =>
19+
execute({
2120
schema,
2221
document,
2322
rootValue: { listField },
24-
});
25-
},
23+
}),
2624
};

benchmark/list-asyncIterable-benchmark.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ async function* listField() {
1313

1414
export const benchmark = {
1515
name: 'Execute Async Iterable List Field',
16-
count: 10,
17-
async measure() {
18-
await execute({
16+
measure: () =>
17+
execute({
1918
schema,
2019
document,
2120
rootValue: { listField },
22-
});
23-
},
21+
}),
2422
};

benchmark/list-sync-benchmark.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ function listField() {
1515

1616
export const benchmark = {
1717
name: 'Execute Synchronous List Field',
18-
count: 10,
19-
async measure() {
20-
await execute({
18+
measure: () =>
19+
execute({
2120
schema,
2221
document,
2322
rootValue: { listField },
24-
});
25-
},
23+
}),
2624
};

benchmark/parser-benchmark.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@ const introspectionQuery = getIntrospectionQuery();
55

66
export const benchmark = {
77
name: 'Parse introspection query',
8-
count: 1000,
9-
measure() {
10-
parse(introspectionQuery);
11-
},
8+
measure: () => parse(introspectionQuery),
129
};

benchmark/printer-benchmark.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@ const document = parse(bigDocumentSDL);
77

88
export const benchmark = {
99
name: 'Print kitchen sink document',
10-
count: 1000,
11-
measure() {
12-
print(document);
13-
},
10+
measure: () => print(document),
1411
};

benchmark/repeated-fields-benchmark.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ const source = `{ ${'hello '.repeat(250)}}`;
66

77
export const benchmark = {
88
name: 'Many repeated fields',
9-
count: 5,
10-
measure() {
11-
graphqlSync({ schema, source });
12-
},
9+
measure: () => graphqlSync({ schema, source }),
1310
};

0 commit comments

Comments
 (0)