-
Notifications
You must be signed in to change notification settings - Fork 4
/
benchmark.ts
47 lines (39 loc) · 1.18 KB
/
benchmark.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// clinic flame -- node -r ts-node/register -r tsconfig-paths/register benchmark.js
import 'reflect-metadata'
import '@Typetron/Support'
import { Handler, Http, Request } from './Router/Http'
import { Container } from './Container'
import { Get } from './Router'
import Method = Http.Method
class Controller {
@Get()
read() {
return 'Hello world!!!'
}
}
async function main() {
const app = new Container()
const handler = app.get(Handler)
handler.addRoute('', Method.GET, Controller, 'read', 'read')
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// const request = await Request.capture({
// url: 'http://localhost:3000',
// method: 'GET',
// headers: {}
// })
// await handler.handle(app, request)
console.time('test')
for (let i = 0; i < 1_000_000_0; i++) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const request = await Request.capture({
url: 'http://localhost:3000',
method: 'GET',
headers: {}
})
await handler.handle(app, request)
}
console.timeEnd('test')
}
main()