Debian Codegraph @

fastify-busboy/bench/fastify-busboy-form-bench-latin1.js

raw
1 'use strict'
2
3 const Busboy = require('../lib/main');
4 const { createMultipartBufferForEncodingBench } = require("./createMultipartBufferForEncodingBench");
5
6 for (var i = 0, il = 10000; i < il; i++) { // eslint-disable-line no-var
7 const boundary = '-----------------------------168072824752491622650073',
8 busboy = new Busboy({
9 headers: {
10 'content-type': 'multipart/form-data; boundary=' + boundary
11 }
12 }),
13 buffer = createMultipartBufferForEncodingBench(boundary, 100, 'iso-8859-1'),
14 mb = buffer.length / 1048576;
15
16 busboy.on('file', (field, file, filename, encoding, mimetype) => {
17 file.resume()
18 })
19
20 busboy.on('error', function (err) {
21 })
22 busboy.on('finish', function () {
23 })
24
25 const start = +new Date();
26 busboy.write(buffer, () => { });
27 busboy.end();
28 const duration = +new Date - start;
29 const mbPerSec = (mb / (duration / 1000)).toFixed(2);
30 console.log(mbPerSec + ' mb/sec');
31 }