Skip to content

Commit d433384

Browse files
committed
Move into benchmark tests
1 parent 0c8b8b6 commit d433384

7 files changed

+67
-35
lines changed

resources/benchmark.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function prepareRevision(revision) {
5353
(cd "${dir}" && yarn install);
5454
fi &&
5555
# Copy in local tests so the same logic applies to each revision.
56-
for file in $(cd "${LOCAL_DIR}src"; find . -path '*/__tests__/*.js');
56+
for file in $(cd "${LOCAL_DIR}src"; find . -path '*/__tests__/*');
5757
do cp "${LOCAL_DIR}src/$file" "${dir}/src/$file";
5858
done &&
5959
(cd "${dir}" && yarn run ${BUILD_CMD})
@@ -82,18 +82,22 @@ function runBenchmark(benchmark, revisions) {
8282
const suite = new Suite(modules[0].name, {
8383
onStart(event) {
8484
console.log('⏱️ ' + event.currentTarget.name);
85+
beautifyBenchmark.reset();
8586
},
8687
onCycle(event) {
8788
beautifyBenchmark.add(event.target);
8889
},
90+
onError(event) {
91+
console.error(event.target.error);
92+
},
8993
onComplete() {
9094
beautifyBenchmark.log();
9195
},
9296
});
9397
for (let i = 0; i < revisions.length; i++) {
9498
suite.add(revisions[i], modules[i].measure);
9599
}
96-
suite.run();
100+
suite.run({ async: false });
97101
}
98102

99103
// Prepare all revisions and run benchmarks matching a pattern against them.

resources/benchmark/run.js

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import { join } from 'path';
9+
import { readFileSync } from 'fs';
10+
import { parse } from '../../';
11+
import { buildASTSchema } from '../buildASTSchema';
12+
13+
const schemaAST = parse(
14+
readFileSync(join(__dirname, 'github-schema.graphql'), 'utf8'),
15+
);
16+
17+
export const name = 'Build Schema from AST';
18+
export function measure() {
19+
buildASTSchema(schemaAST);
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import { join } from 'path';
9+
import { readFileSync } from 'fs';
10+
import { buildClientSchema } from '../buildClientSchema';
11+
12+
const schemaJSON = JSON.parse(
13+
readFileSync(join(__dirname, 'github-schema.json'), 'utf8'),
14+
);
15+
16+
export const name = 'Build Schema from Introspection';
17+
export function measure() {
18+
buildClientSchema(schemaJSON.data);
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import { join } from 'path';
9+
import { readFileSync } from 'fs';
10+
import { execute, parse } from '../../';
11+
import { buildASTSchema } from '../buildASTSchema';
12+
import { getIntrospectionQuery } from '../introspectionQuery';
13+
14+
const queryAST = parse(getIntrospectionQuery());
15+
const schema = buildASTSchema(
16+
parse(readFileSync(join(__dirname, 'github-schema.graphql'), 'utf8')),
17+
);
18+
19+
export const name = 'Execute Introspection Query';
20+
export function measure() {
21+
execute(schema, queryAST);
22+
}

0 commit comments

Comments
 (0)