summaryrefslogtreecommitdiffstats
path: root/fastify-busboy/benchmarks/busboy/executioner.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--fastify-busboy/benchmarks/busboy/executioner.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/fastify-busboy/benchmarks/busboy/executioner.js b/fastify-busboy/benchmarks/busboy/executioner.js
new file mode 100644
index 0000000..524912c
--- /dev/null
+++ b/fastify-busboy/benchmarks/busboy/executioner.js
@@ -0,0 +1,50 @@
+'use strict'
+
+const { process: processBusboy } = require('./contestants/busboy')
+const { process: processFastify } = require('./contestants/fastify-busboy')
+const { getCommonBuilder } = require('../common/commonBuilder')
+const { validateAccuracy } = require('./validator')
+const { resolveContestant } = require('../common/contestantResolver')
+const { outputResults } = require('../common/resultUtils')
+
+const contestants = {
+ busboy: measureBusboy,
+ fastify: measureFastify
+}
+
+async function measureBusboy () {
+ const benchmark = getCommonBuilder()
+ .benchmarkName('Busboy comparison')
+ .benchmarkEntryName('busboy')
+ .asyncFunctionUnderTest(processBusboy)
+ .build()
+ const benchmarkResults = await benchmark.executeAsync()
+ outputResults(benchmark, benchmarkResults)
+}
+
+async function measureFastify () {
+ const benchmark = getCommonBuilder()
+ .benchmarkName('Busboy comparison')
+ .benchmarkEntryName('fastify-busboy')
+ .asyncFunctionUnderTest(processFastify)
+ .build()
+ const benchmarkResults = await benchmark.executeAsync()
+ outputResults(benchmark, benchmarkResults)
+}
+
+function execute () {
+ return validateAccuracy(processBusboy())
+ .then(() => {
+ return validateAccuracy(processFastify())
+ })
+ .then(() => {
+ const contestant = resolveContestant(contestants)
+ return contestant()
+ }).then(() => {
+ console.log('all done')
+ }).catch((err) => {
+ console.error(`Something went wrong: ${err.message}`)
+ })
+}
+
+execute()