From 25235b48e2632609a0550b5b03de7d70a67f61cf Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 14 Sep 2017 20:17:22 -0400 Subject: [PATCH] bench: remove object setup from op time --- benchmark/index.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index bffcd02..886b4aa 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -10,33 +10,36 @@ var benchmarks = require('beautify-benchmark') * Globals for benchmark.js */ -global.fakerequest = fakerequest global.forwarded = require('..') +global.req0 = fakerequest({}) +global.req1 = fakerequest({ 'x-forwarded-for': '192.168.0.10' }) +global.req2 = fakerequest({ 'x-forwarded-for': '192.168.0.10, 192.168.1.20' }) +global.req5 = fakerequest({ 'x-forwarded-for': '192.168.0.10, 192.168.1.20, 192.168.1.21, 192.168.1.22, 192.168.1.23' }) var suite = new benchmark.Suite() suite.add({ name: 'no header', minSamples: 100, - fn: 'var addrs = forwarded(fakerequest({}))' + fn: 'var addrs = forwarded(req0)' }) suite.add({ name: '1 address', minSamples: 100, - fn: 'var addrs = forwarded(fakerequest({ "x-forwarded-for": "192.168.0.10" }))' + fn: 'var addrs = forwarded(req1)' }) suite.add({ name: '2 addresses', minSamples: 100, - fn: 'var addrs = forwarded(fakerequest({ "x-forwarded-for": "192.168.0.10, 192.168.1.20" }))' + fn: 'var addrs = forwarded(req2)' }) suite.add({ name: '5 addresses', minSamples: 100, - fn: 'var addrs = forwarded(fakerequest({ "x-forwarded-for": "192.168.0.10, 192.168.1.20, 192.168.1.21, 192.168.1.22, 192.168.1.23" }))' + fn: 'var addrs = forwarded(req5)' }) suite.on('cycle', function onCycle (event) {