Skip to content
Merged
Changes from 1 commit
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
Next Next commit
test: Fixed recordMiddlewawre benchmark test
  • Loading branch information
bizob2828 committed Jul 9, 2024
commit bb150b32bcc3556cce01eaf954443ffc514c8d26
13 changes: 7 additions & 6 deletions test/benchmark/webframework-shim/recordMiddleware.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const symbols = require('../../../lib/symbols')
const agent = helper.loadMockedAgent()
const contextManager = helper.getContextManager()
const shim = new WebFrameworkShim(agent, 'test-module', './')
const { MiddlewareSpec } = require('../../../lib/shim/specs')
const suite = benchmark.createBenchmark({ name: 'recordMiddleware' })

const transaction = helper.runInTransaction(agent, function (tx) {
Expand Down Expand Up @@ -93,26 +94,26 @@ function getReqd() {
}

function implicitSpec() {
return {}
return new MiddlewareSpec({})
}

function partialSpec() {
return {
return new MiddlewareSpec({
next: shim.LAST,
req: shim.FIRST
}
})
}

function explicitSpec() {
return {
return new MiddlewareSpec({
req: shim.FIRST,
res: shim.SECOND,
next: shim.LAST,
name: 'funcy_name',
params: function (shim, fn, name, args) {
return args[0].params
}
}
})
}

function randomSpec() {
Expand Down Expand Up @@ -144,7 +145,7 @@ function noop() {}

function preOptRecordMiddleware() {
for (let i = 0; i < 1000; ++i) {
let m = randomRecord(randomSpec)
let m = randomRecord(randomSpec())
m = typeof m === 'function' ? m : m.func
for (let j = 0; j < 100; ++j) {
m(getReqd(), {}, noop)
Expand Down