Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmark introspecting a schema built from SDL in a supplied file. #1163

Merged
merged 2 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions resources/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function prepareRevision(revision) {
(cd "${dir}" && yarn install);
fi &&
# Copy in local tests so the same logic applies to each revision.
for file in $(cd "${LOCAL_DIR}src"; find . -path '*/__tests__/*.js');
for file in $(cd "${LOCAL_DIR}src"; find . -path '*/__tests__/*');
do cp "${LOCAL_DIR}src/$file" "${dir}/src/$file";
done &&
(cd "${dir}" && yarn run ${BUILD_CMD})
Expand Down Expand Up @@ -82,18 +82,22 @@ function runBenchmark(benchmark, revisions) {
const suite = new Suite(modules[0].name, {
onStart(event) {
console.log('⏱️ ' + event.currentTarget.name);
beautifyBenchmark.reset();
},
onCycle(event) {
beautifyBenchmark.add(event.target);
},
onError(event) {
console.error(event.target.error);
},
onComplete() {
beautifyBenchmark.log();
},
});
for (let i = 0; i < revisions.length; i++) {
suite.add(revisions[i], modules[i].measure);
}
suite.run();
suite.run({ async: false });
}

// Prepare all revisions and run benchmarks matching a pattern against them.
Expand Down
20 changes: 20 additions & 0 deletions src/utilities/__tests__/buildASTSchema-benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { join } from 'path';
import { readFileSync } from 'fs';
import { parse } from '../../';
import { buildASTSchema } from '../buildASTSchema';

const schemaAST = parse(
readFileSync(join(__dirname, 'github-schema.graphql'), 'utf8'),
);

export const name = 'Build Schema from AST';
export function measure() {
buildASTSchema(schemaAST);
}
19 changes: 19 additions & 0 deletions src/utilities/__tests__/buildClientSchema-benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import { join } from 'path';
import { readFileSync } from 'fs';
import { buildClientSchema } from '../buildClientSchema';

const schemaJSON = JSON.parse(
readFileSync(join(__dirname, 'github-schema.json'), 'utf8'),
);

export const name = 'Build Schema from Introspection';
export function measure() {
buildClientSchema(schemaJSON.data);
}
Loading