|
2 | 2 |
|
3 | 3 | const { fork } = require('child_process') |
4 | 4 | const { join } = require('path') |
| 5 | +const { writeFileSync } = require('fs') |
5 | 6 | const { get } = require('axios') |
6 | 7 | const autocannon = require('autocannon') |
7 | 8 | const table = require('tty-table') |
| 9 | +const warmupSec = 1 |
| 10 | +const runSec = 1 |
8 | 11 | const ports = { |
9 | 12 | http: 3010, |
10 | 13 | fastify: 3011, |
@@ -85,8 +88,8 @@ const bencher = (title) => new Promise((resolve, reject) => { |
85 | 88 | pipelining: lob ? 1 : 10, |
86 | 89 | headers: { 'accept-encoding': 'gzip, deflate, br' } |
87 | 90 | } |
88 | | - autocannon(Object.assign({ duration: 3 }, acOpts), () => { |
89 | | - autocannon(Object.assign({ duration: 7 }, acOpts), done) |
| 91 | + autocannon(Object.assign({ duration: warmupSec }, acOpts), () => { |
| 92 | + autocannon(Object.assign({ duration: runSec }, acOpts), done) |
90 | 93 | }) |
91 | 94 | }) |
92 | 95 |
|
@@ -147,6 +150,28 @@ async function bench () { |
147 | 150 | memory[r.title].end.split('/').map(formatBytes).join('\n') |
148 | 151 | ]) |
149 | 152 |
|
150 | | - console.log(table(head, rows).render()) |
| 153 | + const consoleOut = table(head, rows).render() |
| 154 | + console.log(consoleOut) |
| 155 | + |
| 156 | + const borderCharacters = [ |
| 157 | + [ |
| 158 | + { v: ' ', l: ' ', j: ' ', h: ' ', r: ' ' }, |
| 159 | + { v: ' ', l: ' ', j: ' ', h: ' ', r: ' ' }, |
| 160 | + { v: ' ', l: ' ', j: ' ', h: ' ', r: ' ' } |
| 161 | + ], |
| 162 | + [ |
| 163 | + { v: '|', l: '+', j: '+', h: '-', r: '+' }, |
| 164 | + { v: '|', l: '+', j: '+', h: '-', r: '+' }, |
| 165 | + { v: '|', l: '+', j: '+', h: '-', r: '+' } |
| 166 | + ], |
| 167 | + [ |
| 168 | + { v: '|', l: '+', j: '+', h: '-', r: '+' }, |
| 169 | + { v: '|', l: '+', j: '+', h: '-', r: '+' }, |
| 170 | + { v: '|', l: '+', j: '+', h: '-', r: '+' } |
| 171 | + ] |
| 172 | + ] |
| 173 | + const headerColor = null |
| 174 | + const fileOut = table(head, rows, { borderCharacters, headerColor }).render() |
| 175 | + writeFileSync('results.txt', fileOut, 'utf8') |
151 | 176 | process.exit() |
152 | 177 | } |
0 commit comments