Skip to content

Instantly share code, notes, and snippets.

@Chriscbr
Created August 27, 2023 01:57
Show Gist options
  • Save Chriscbr/fa69e5f7f35d5aa4dc312dd7025952b1 to your computer and use it in GitHub Desktop.
Save Chriscbr/fa69e5f7f35d5aa4dc312dd7025952b1 to your computer and use it in GitHub Desktop.
constructs benchmarking
import { Construct } from "constructs";
class App extends Construct {
constructor() {
super(undefined as any, '');
}
}
class L0 extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
}
}
class L1 extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
for (let i = 0; i < 100; i++) {
new L0(this, `l1-${i}`);
}
}
}
class L2 extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
for (let i = 0; i < 100; i++) {
new L1(this, `l1-${i}`);
}
}
}
class L3 extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
for (let i = 0; i < 100; i++) {
new L2(this, `l2-${i}`);
}
}
}
console.time("construct");
const app = new App();
new L3(app, 'l3');
console.timeEnd("construct");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment