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

Establish baseline for select type instantiations #829

Merged
merged 3 commits into from
Jan 5, 2024
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
9 changes: 5 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
edgedb-version: ["stable"]
include:
- os: ubuntu-latest
node-version: "18"
node-version: "20"
edgedb-version: "nightly"
- os: ubuntu-latest
node-version: "18"
node-version: "20"
edgedb-version: "3"
- os: ubuntu-latest
node-version: "18"
node-version: "20"
edgedb-version: "2"
- os: macos-latest
node-version: "18"
node-version: "20"
edgedb-version: "stable"

steps:
Expand Down Expand Up @@ -107,6 +107,7 @@ jobs:
if: ${{ matrix.edgedb-version == '3' || matrix.edgedb-version == 'stable' || matrix.edgedb-version == 'nightly' }}
run: |
yarn workspace @edgedb/integration-lts test:ci
yarn workspace @edgedb/integration-lts run bench:types

- name: Run query builder integration tests stable
if: ${{ matrix.edgedb-version == 'stable' || matrix.edgedb-version == 'nightly' }}
Expand Down
98 changes: 98 additions & 0 deletions integration-tests/lts/bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { bench } from "@arktype/attest";

import e from "./dbschema/edgeql-js";

bench("select: scalar", () => {
const query = e.select(e.int32(42));
return {} as typeof query;
}).types([1263, "instantiations"]);

bench("select: free object", () => {
const query = e.select({ meaning: e.int32(42) });
return {} as typeof query;
}).types([2120, "instantiations"]);

bench("select: id only", () => {
const query = e.select(e.User, () => ({ id: true }));
return {} as typeof query;
}).types([3642, "instantiations"]);

bench("select: filtered", () => {
const query = e.select(e.User, () => ({
filter_single: { id: e.uuid("123") },
}));
return {} as typeof query;
}).types([5384, "instantiations"]);

bench("select: nested", () => {
const user = e.select(e.User, () => ({
filter_single: { id: e.uuid("123") },
}));
const query = e.select(user, () => ({ id: true }));

return {} as typeof query;
}).types([7412, "instantiations"]);

bench("select: complex", () => {
const query = e.select(e.Movie, () => ({
id: true,
characters: (char) => ({
name: true,
"@character_name": true,
filter: e.op(char["@character_name"], "=", "Tony Stark"),
}),
}));
return {} as typeof query;
}).types([6339, "instantiations"]);

bench("select: with filter", () => {
const query = e.select(e.Hero, (hero) => ({
name: true,
villains: {
id: true,
name: true,
},
filter_single: e.op(hero.name, "=", "Peter Parker"),
}));
return {} as typeof query;
}).types([98669, "instantiations"]);

bench("select: with order", () => {
const query = e.select(e.Hero, (hero) => ({
name: true,
villains: (v) => ({
id: true,
name: true,
order_by: v.name,
}),
filter_single: e.op(hero.name, "=", "Peter Parker"),
}));
return {} as typeof query;
}).types([98963, "instantiations"]);

bench("select: with limit", () => {
const query = e.select(e.Hero, (hero) => ({
name: true,
villains: () => ({
id: true,
name: true,
limit: 1,
}),
filter_single: e.op(hero.name, "=", "Peter Parker"),
}));
return {} as typeof query;
}).types([98694, "instantiations"]);

bench("select: with offset", () => {
const query = e.select(e.Hero, (hero) => ({
name: true,
villains: (v) => ({
id: true,
name: true,
offset: 1,
}),
filter_single: e.op(hero.name, "=", "Peter Parker"),
}));
return {} as typeof query;
}).types([98730, "instantiations"]);

4 changes: 3 additions & 1 deletion integration-tests/lts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"test:cjs": "yarn generate queries --target cjs --file cjs/queries && yarn generate edgeql-js --target cjs --output-dir cjs/edgeql-js && cd cjs && node test.js",
"test:mts": "yarn generate queries --target mts --file mts/queries && yarn generate edgeql-js --target mts --output-dir mts/edgeql-js && cd mts && yarn build && node dist/test.js",
"test:deno": "cd deno && deno task edgeql-js && deno task queries && deno task play",
"test:ci": "tsx ./testRunner.ts"
"test:ci": "tsx ./testRunner.ts",
"bench:types": "cd ../.. && tsx integration-tests/lts/bench.ts"
},
"devDependencies": {
"@arktype/attest": "^0.5.0",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.2",
"conditional-type-checks": "^1.0.6",
Expand Down
32 changes: 32 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@
"@jridgewell/gen-mapping" "^0.3.0"
"@jridgewell/trace-mapping" "^0.3.9"

"@arktype/attest@^0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@arktype/attest/-/attest-0.5.0.tgz#bee97b89603af05ca77a5aed07cef77f746d386b"
integrity sha512-MRWnjq2rAJLhPZP9GqWHLyIOBomzxcJxHdzANNcEZV/EXdutS4YumdoHi3NEsk6zt0kscqk4reRRPnUa2zwhrQ==
dependencies:
"@arktype/fs" "0.0.10"
"@arktype/util" "0.0.16"
"@typescript/vfs" "1.5.0"
arktype latest

"@arktype/fs@0.0.10":
version "0.0.10"
resolved "https://registry.yarnpkg.com/@arktype/fs/-/fs-0.0.10.tgz#2d728c99856554a08725b81d970bd1dc1a4e0d91"
integrity sha512-aPYLmcdS7eHUftTQOyPZRdoMWrvuk4m0LwO6dB9fwKqJTngnizWAeP0AS+tMincPhdZEahRyX0ju9Czvdm/zkQ==

"@arktype/util@0.0.16":
version "0.0.16"
resolved "https://registry.yarnpkg.com/@arktype/util/-/util-0.0.16.tgz#2401e3ac238f135ab1fa81ad4f849d0783318534"
integrity sha512-a10hhQ5E95tV0wfi8N9/74Uo6mRDHjeGWaHsyZriq4a9srZ9AbJ3UlYUQfIaQgsxLIuMw3kdClsE/H3tMdZKvw==

"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.18.6", "@babel/code-frame@^7.21.4":
version "7.21.4"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.21.4.tgz#d0fa9e4413aca81f2b23b9442797bda1826edb39"
Expand Down Expand Up @@ -1459,6 +1479,13 @@
"@typescript-eslint/types" "5.60.1"
eslint-visitor-keys "^3.3.0"

"@typescript/vfs@1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@typescript/vfs/-/vfs-1.5.0.tgz#ed942922724f9ace8c07c80b006c47e5e3833218"
integrity sha512-AJS307bPgbsZZ9ggCT3wwpg3VbTKMFNHfaY/uF0ahSkYYrPF2dSSKDNIDIQAHm9qJqbLvCsSJH7yN4Vs/CsMMg==
dependencies:
debug "^4.1.1"

"@web3-storage/multipart-parser@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@web3-storage/multipart-parser/-/multipart-parser-1.0.0.tgz#6b69dc2a32a5b207ba43e556c25cc136a56659c4"
Expand Down Expand Up @@ -1568,6 +1595,11 @@ argparse@^2.0.1:
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==

arktype@latest:
version "1.0.28-alpha"
resolved "https://registry.yarnpkg.com/arktype/-/arktype-1.0.28-alpha.tgz#26cb8ea9fef86a4dbae4868d6e5ba98b5f34f5b7"
integrity sha512-cjakiZXXa4+y1OL0oFk0HRjIrEwJhNNvkqXkiR53SOpyKHwSqFrjrQkY4K8MlnQybRhd/y4OG4NVDR1Ea4WDkQ==

array-flatten@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"
Expand Down
Loading