Debian Codegraph @

fastify-busboy/bench/parse-params.js

raw
1 'use strict'
2
3 const parseParams = require('../lib/utils/parseParams')
4 const { Bench } = require('tinybench');
5 const bench = new Bench();
6
7 const simple = 'video/ogg'
8 const complex = "'text/plain; filename*=utf-8''%c2%a3%20and%20%e2%82%ac%20rates'"
9
10 bench
11 .add(simple, function () { parseParams(simple) })
12 .add(complex, function () { parseParams(complex) })
13 .run()
14 .then((tasks) => {
15 const errors = tasks.map(t => t.result?.error).filter((t) => t)
16 if (errors.length) {
17 errors.map((e) => console.error(e))
18 } else {
19 console.table(bench.table())
20 }
21 })