Skip to content

Commit

Permalink
Bump TypeScript to benchmark type perf regression
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh committed Mar 25, 2024
1 parent d8530bf commit 57cc662
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
46 changes: 23 additions & 23 deletions integration-tests/lts/bench.ts
Expand Up @@ -5,65 +5,65 @@ import e from "./dbschema/edgeql-js";
bench("e.literal: scalar", () => {
const lit = e.literal(e.int32, 42);
return {} as typeof lit;
}).types([992, "instantiations"]);
}).types([4468, "instantiations"]);

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

bench("e.str: scalar", () => {
const lit = e.str("abcd");
return {} as typeof lit;
}).types([894, "instantiations"]);
}).types([897, "instantiations"]);

bench("e.literal: array literal", () => {
const lit = e.literal(e.array(e.str), ["abcd"]);
return {} as typeof lit;
}).types([4095, "instantiations"]);
}).types([7568, "instantiations"]);

bench("e.array: array literal", () => {
const lit = e.array([e.str("abcd")]);
return {} as typeof lit;
}).types([2599, "instantiations"]);
}).types([2606, "instantiations"]);

bench("e.literal: named tuple literal", () => {
const lit = e.literal(e.tuple({ str: e.str }), {
str: "asdf",
});
return {} as typeof lit;
}).types([10996, "instantiations"]);
}).types([16528, "instantiations"]);

bench("e.tuple: named tuple literal", () => {
const lit = e.tuple({ str: e.str("asdf") });
return {} as typeof lit;
}).types([7796, "instantiations"]);
}).types([9831, "instantiations"]);

bench("e.literal: tuple literal", () => {
const lit = e.literal(e.tuple([e.str, e.int32]), ["asdf", 42]);
return {} as typeof lit;
}).types([7600, "instantiations"]);
}).types([13125, "instantiations"]);

bench("e.tuple: tuple literal", () => {
const lit = e.tuple([e.str("asdf"), e.int32(42)]);
return {} as typeof lit;
}).types([4836, "instantiations"]);
}).types([4889, "instantiations"]);

bench("e.literal: array of tuples", () => {
const lit = e.literal(e.array(e.tuple([e.str, e.int32])), [
["asdf", 42],
["qwer", 43],
]);
return {} as typeof lit;
}).types([10191, "instantiations"]);
}).types([15721, "instantiations"]);

bench("e.array: array of tuples", () => {
const lit = e.array([
e.tuple([e.str("asdf"), e.int32(42)]),
e.tuple([e.str("qwer"), e.int32(43)]),
]);
return {} as typeof lit;
}).types([20613, "instantiations"]);
}).types([22894, "instantiations"]);

bench("base type: array", () => {
const baseType = e.array(e.str);
Expand All @@ -73,29 +73,29 @@ bench("base type: array", () => {
bench("base type: named tuple", () => {
const baseType = e.tuple({ str: e.str });
return {} as typeof baseType;
}).types([3564, "instantiations"]);
}).types([3545, "instantiations"]);

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

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

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

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

bench("select: nested", () => {
const user = e.select(e.User, () => ({
Expand All @@ -104,7 +104,7 @@ bench("select: nested", () => {
const query = e.select(user, () => ({ id: true }));

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

bench("select: complex", () => {
const query = e.select(e.Movie, () => ({
Expand All @@ -116,7 +116,7 @@ bench("select: complex", () => {
}),
}));
return {} as typeof query;
}).types([6352, "instantiations"]);
}).types([6374, "instantiations"]);

bench("select: with filter", () => {
const query = e.select(e.Hero, (hero) => ({
Expand All @@ -128,7 +128,7 @@ bench("select: with filter", () => {
filter_single: e.op(hero.name, "=", "Peter Parker"),
}));
return {} as typeof query;
}).types([6428, "instantiations"]);
}).types([6447, "instantiations"]);

bench("select: with order", () => {
const query = e.select(e.Hero, (hero) => ({
Expand All @@ -141,7 +141,7 @@ bench("select: with order", () => {
filter_single: e.op(hero.name, "=", "Peter Parker"),
}));
return {} as typeof query;
}).types([6765, "instantiations"]);
}).types([6786, "instantiations"]);

bench("select: with limit", () => {
const query = e.select(e.Hero, (hero) => ({
Expand All @@ -154,7 +154,7 @@ bench("select: with limit", () => {
filter_single: e.op(hero.name, "=", "Peter Parker"),
}));
return {} as typeof query;
}).types([6490, "instantiations"]);
}).types([6510, "instantiations"]);

bench("select: with offset", () => {
const query = e.select(e.Hero, (hero) => ({
Expand All @@ -167,7 +167,7 @@ bench("select: with offset", () => {
filter_single: e.op(hero.name, "=", "Peter Parker"),
}));
return {} as typeof query;
}).types([6533, "instantiations"]);
}).types([6553, "instantiations"]);

bench("params select", () => {
const query = e.params({ name: e.str }, (params) =>
Expand All @@ -181,4 +181,4 @@ bench("params select", () => {
}))
);
return {} as typeof query;
}).types([11248, "instantiations"]);
}).types([12010, "instantiations"]);
1 change: 1 addition & 0 deletions packages/generate/src/syntax/literal.ts
Expand Up @@ -35,6 +35,7 @@ export function literal<T extends BaseType>(
__element__: type,
__cardinality__: Cardinality.One,
__kind__: ExpressionKind.Literal,
// @ts-expect-error: Type instantiation error
__value__: value,
}) as any;
}
Expand Down

0 comments on commit 57cc662

Please sign in to comment.