forked from typeorm/typeorm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add benchmark for select querybuilder (typeorm#8955)
Motivation: the query builder (and within it, replacePropertyNames and associated functions) is pretty CPU intensive. For our workload, it's one of the hottest functions in our entire stack. While improved in typeorm#4760, There are still outstanding issues relating to perf e.g. typeorm#3857 As we all know though, the first step in optimization is to measure systematically ;) https://wiki.c2.com/?ProfileBeforeOptimizing On my machine, this benchmark runs in ~3500ms or about 0.35ms/query. This tells us there's a way to go - on my stack, that's about 1/3 of a typical query's latency!
- Loading branch information
Showing
11 changed files
with
472 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
test/benchmark/multiple-joins-querybuilder/entity/Eight.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { One } from "./One" | ||
import { ManyToOne } from "../../../../src" | ||
|
||
@Entity() | ||
export class Eight { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@ManyToOne((type) => One) | ||
one: One | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { One } from "./One" | ||
import { ManyToOne } from "../../../../src" | ||
|
||
@Entity() | ||
export class Five { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@ManyToOne((type) => One) | ||
one: One | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { One } from "./One" | ||
import { ManyToOne } from "../../../../src" | ||
|
||
@Entity() | ||
export class Four { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@ManyToOne((type) => One) | ||
one: One | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { One } from "./One" | ||
import { ManyToOne } from "../../../../src" | ||
|
||
@Entity() | ||
export class Nine { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@ManyToOne((type) => One) | ||
one: One | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { OneToOne } from "../../../../src" | ||
import { Two } from "./Two" | ||
import { Three } from "./Three" | ||
import { Four } from "./Four" | ||
import { Five } from "./Five" | ||
import { Six } from "./Six" | ||
import { Seven } from "./Seven" | ||
import { Eight } from "./Eight" | ||
import { Nine } from "./Nine" | ||
import { Ten } from "./Ten" | ||
|
||
@Entity() | ||
export class One { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@OneToOne((type) => Two, (two) => two.one) | ||
two: Two | ||
|
||
@OneToOne((type) => Three, (three) => three.one) | ||
three: Three | ||
|
||
@OneToOne((type) => Four, (four) => four.one) | ||
four: Four | ||
|
||
@OneToOne((type) => Five, (five) => five.one) | ||
five: Five | ||
|
||
@OneToOne((type) => Six, (six) => six.one) | ||
six: Six | ||
|
||
@OneToOne((type) => Seven, (seven) => seven.one) | ||
seven: Seven | ||
|
||
@OneToOne((type) => Eight, (eight) => eight.one) | ||
eight: Eight | ||
|
||
@OneToOne((type) => Nine, (nine) => nine.one) | ||
nine: Nine | ||
|
||
@OneToOne((type) => Ten, (ten) => ten.one) | ||
ten: Ten | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
|
||
@Column({ type: "text" }) | ||
iiiii: string | ||
} |
38 changes: 38 additions & 0 deletions
38
test/benchmark/multiple-joins-querybuilder/entity/Seven.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { One } from "./One" | ||
import { ManyToOne } from "../../../../src" | ||
|
||
@Entity() | ||
export class Seven { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@ManyToOne((type) => One) | ||
one: One | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { One } from "./One" | ||
import { ManyToOne } from "../../../../src" | ||
|
||
@Entity() | ||
export class Six { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@ManyToOne((type) => One) | ||
one: One | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { One } from "./One" | ||
import { ManyToOne } from "../../../../src" | ||
|
||
@Entity() | ||
export class Ten { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@ManyToOne((type) => One) | ||
one: One | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
} |
38 changes: 38 additions & 0 deletions
38
test/benchmark/multiple-joins-querybuilder/entity/Three.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { One } from "./One" | ||
import { ManyToOne } from "../../../../src" | ||
|
||
@Entity() | ||
export class Three { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@ManyToOne((type) => One) | ||
one: One | ||
|
||
@Column({ type: "text" }) | ||
aaaaa: string | ||
|
||
@Column({ type: "text" }) | ||
bbbbb: string | ||
|
||
@Column({ type: "text" }) | ||
ccccc: string | ||
|
||
@Column({ type: "text" }) | ||
ddddd: string | ||
|
||
@Column({ type: "text" }) | ||
eeeee: string | ||
|
||
@Column({ type: "text" }) | ||
fffff: string | ||
|
||
@Column({ type: "text" }) | ||
ggggg: string | ||
|
||
@Column({ type: "text" }) | ||
hhhhh: string | ||
} |
Oops, something went wrong.