Skip to content

Commit e7fb39b

Browse files
committed
Make it easier to update benchmark results
1 parent 08233d5 commit e7fb39b

8 files changed

Lines changed: 2738 additions & 17 deletions

File tree

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,15 @@ Every resource has corresponding SCRUD actions which are expressed in the HTTP m
3434

3535
# is it fast
3636

37-
Glad you asked. Yes, it is.
37+
It is competitively fast. It's neither the fastest thing out there or the slowest, but it strives to be competitive with the fastest of the bunch.
3838

3939
# benchmarks
4040

4141
As always, take benches with a grain of salt. The point is that we care about performance and optimize for it. To see benchmarking details check out the bench directory. The gist is this, all libs return a simple JSON response and the proper content-type headers. Each server is run in their own forked process and gets a warm up run for 3 seconds before we start tracking the results.
4242

43-
Node's `http` built-in is given the advantage of pre-rendered JSON, as it is the benchmark. SCRUD and Polka bounce back and forth in second position. To be clear SCRUD only handles resourceful SCRUD routes, Polka packs a more capable router which handles less standardized routes and an Express compatible middleware handler. SCRUD is focused on APIs and microservices.
44-
45-
<div align="center" style="box-shadow: -4px 2px 6px rgba(0,0,0,0.4);">
46-
<img src="https://github.com/doesdev/scrud/raw/master/assets/bench.png" alt="SCRUD" />
47-
</div>
43+
Node's `http` built-in is given the advantage of pre-rendered JSON, as it is the benchmark.
4844

45+
![Benchmark](bench/results.png)
4946

5047
# install
5148

assets/bench.png

-21 KB
Binary file not shown.

bench/.carbon.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"bench": {
3+
"bg": "rgba(71,72,73,1)",
4+
"t": "dracula",
5+
"wt": "none",
6+
"l": "auto",
7+
"ds": "true",
8+
"dsyoff": "20px",
9+
"dsblur": "68px",
10+
"wc": "true",
11+
"wa": "true",
12+
"pv": "48px",
13+
"ph": "32px",
14+
"ln": "false",
15+
"fm": "Hack",
16+
"fs": "14px",
17+
"lh": "133%",
18+
"si": "false",
19+
"es": "2x",
20+
"wm": "false"
21+
}
22+
}

bench/index.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
const { fork } = require('child_process')
44
const { join } = require('path')
5+
const { writeFileSync } = require('fs')
56
const { get } = require('axios')
67
const autocannon = require('autocannon')
78
const table = require('tty-table')
9+
const warmupSec = 1
10+
const runSec = 1
811
const ports = {
912
http: 3010,
1013
fastify: 3011,
@@ -85,8 +88,8 @@ const bencher = (title) => new Promise((resolve, reject) => {
8588
pipelining: lob ? 1 : 10,
8689
headers: { 'accept-encoding': 'gzip, deflate, br' }
8790
}
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)
9093
})
9194
})
9295

@@ -147,6 +150,28 @@ async function bench () {
147150
memory[r.title].end.split('/').map(formatBytes).join('\n')
148151
])
149152

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')
151176
process.exit()
152177
}

0 commit comments

Comments
 (0)