-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.bench.ts
25 lines (24 loc) · 1.01 KB
/
application.bench.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { assertEquals } from './vendor/https/deno.land/std/testing/asserts.ts';
import { MainModule as BasicInjectionModule } from './examples/basic-injection/main.module.ts';
import { MainModule as CircularDependenciesModule } from './examples/circular-dependencies/main.module.ts';
import { MainModule as TwoConsumersModule } from './examples/two-consumers/main.module.ts';
import { Application } from './mod.ts';
Deno.bench('empty application', async () => {
const app = new Application(class SomeModule {});
let resolver: (value: boolean) => void;
const promise = new Promise<boolean>((r) => resolver = r);
app.hook({ application: app, scope: 'post' }, () => {
resolver(true);
});
app.boot();
assertEquals(await promise, true);
});
Deno.bench('basic injections', () => {
new Application(BasicInjectionModule).boot();
});
Deno.bench('circular dependencies', () => {
new Application(CircularDependenciesModule).boot();
});
Deno.bench('two consumers', () => {
new Application(TwoConsumersModule).boot();
});