Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions benchmark/scenarios/body-json-512kb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

// The other body-parser scenario posts 57 bytes, which uWS hands over in a single
// chunk, so it never exercises the accumulate path. This one is large enough to
// arrive in several chunks and makes the cost of collecting a body visible.
const PAD = 512 * 1024;

module.exports = {
name: 'middlewares/body-json-512kb',
path: '/abc',
wrk: {
script: 'post-json-512kb.lua',
connections: 50
},
verify: {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ n: 1, pad: 'x'.repeat(PAD) })
},
setup(app, express) {
app.use(express.json({ limit: '10mb' }));
app.post('/abc', (req, res) => {
res.send(`${req.body.pad.length}`);
});
}
};
7 changes: 7 additions & 0 deletions benchmark/wrk-scripts/post-json-512kb.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
wrk.method = "POST"
wrk.path = "/abc"
wrk.headers["Content-Type"] = "application/json"

local kb = 1024
local pad = string.rep("x", 512 * kb)
wrk.body = '{"n":1,"pad":"' .. pad .. '"}'
Loading