Skip to content

Commit 68516ee

Browse files
committed
📘 chore: add decorate stress test
1 parent 428b976 commit 68516ee

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

example/stress/decorate.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Elysia, t } from '../../src'
2+
3+
const total = 1000
4+
const sub = 50
5+
6+
const app = new Elysia()
7+
8+
const memory = process.memoryUsage().heapTotal / 1024 / 1024
9+
console.log(`${total} Elysia instances with ${sub} decorations each`)
10+
11+
const t1 = performance.now()
12+
13+
for (let i = 0; i < total; i++) {
14+
const plugin = new Elysia()
15+
16+
for (let j = 0; j < sub; j++)
17+
plugin.decorate('a', {
18+
[`value-${i * sub + j}`]: 1
19+
})
20+
21+
app.use(plugin)
22+
}
23+
24+
const t2 = performance.now()
25+
26+
Bun.gc(true)
27+
28+
const memoryAfter = process.memoryUsage().heapTotal / 1024 / 1024
29+
console.log(+(memoryAfter - memory).toFixed(2), 'MB memory used')
30+
console.log(+(t2 - t1).toFixed(2), 'ms')

0 commit comments

Comments
 (0)