Skip to content

Commit

Permalink
fix the hanging
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyguerra committed Jan 7, 2024
1 parent 2cd7a0d commit edec01f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
11 changes: 11 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,14 @@ Redesigned Express to not create a prototype chain on the req/res objects. The f
| Req/Sec | 56,255 | 56,255 | 64,511 | 66,495 | 63,388.8 | 3,687.84 | 56,241 |
| Bytes/Sec | 13.4 MB | 13.4 MB | 15.4 MB | 15.8 MB | 15.1 MB | 877 kB | 13.4 MB |

## Version 3 - 1/6/2024, 7:19:01 PM

| Stat | 2.5% | 50% | 97.5% | 99% | Avg | Stdev | Max |
|:-----|:----:|:---:|:-----:|:---:|:---:|:-----:|:---:|
| Latency | 8 ms | 18 ms | 20 ms | 22 ms | 15.4 ms | 18.39 ms | 667 ms |

| Stat | 1% | 2.5% | 50% | 97.5% | Avg | Stdev | Min |
|:-----|:--:|:----:|:---:|:-----:|:---:|:-----:|:---:|
| Req/Sec | 52,095 | 52,095 | 65,439 | 65,855 | 62,758.4 | 5,344.96 | 52,088 |
| Bytes/Sec | 12.4 MB | 12.4 MB | 15.6 MB | 15.7 MB | 14.9 MB | 1.27 MB | 12.4 MB |

28 changes: 13 additions & 15 deletions benchmarks/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,20 @@ while (n--) {
app.use((req, res) => {
res.send('Hello World')
})
app.on('listening', function () {
const { port } = this.address()
autocannon({
url: `http://localhost:${port}/?foo[bar]=baz`,
pipelining: 10,
connections: 100,
duration: 5,
title: 'Version 3',
workers: 4
}, (err, result) => {
console.log(toTable(result))
fs.appendFile(`benchmarks/README.md`, `## ${result.title} - ${new Date().toLocaleString()}
const server = app.listen()
const { port } = server.address()
autocannon({
url: `http://localhost:${port}/?foo[bar]=baz`,
pipelining: 10,
connections: 100,
duration: 5,
title: 'Version 3',
workers: 4
}, (err, result) => {
console.log(toTable(result))
fs.appendFile(`benchmarks/README.md`, `## ${result.title} - ${new Date().toLocaleString()}
${toTable(result)}\n`, 'utf8', () => {
server.close()
})
server.close()
})
})
const server = app.listen()

2 changes: 1 addition & 1 deletion lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ class ExpressApp extends EventEmitter {

listen(...args) {
this.#server = http.createServer({ IncomingMessage: ExpressRequest, ServerResponse: ExpressResponse }, this.handle.bind(this))
return this.#server.listen(...args, () => this.emit('listening'))
return this.#server.listen(...args)
}
address () {
return this.#server?.address() ?? null
Expand Down

0 comments on commit edec01f

Please sign in to comment.