Skip to content

Commit

Permalink
test: Updated shimmer method in benchmark tests (#2281)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrickard committed Jun 25, 2024
1 parent 8e06f0f commit 1528d68
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions test/benchmark/shimmer/instrumentation.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ const shimmer = require('../../../lib/shimmer')
const suite = benchmark.createBenchmark({ name: 'shimmer wrapping', delay: 0.01 })

suite.add({
name: 'shimmer.patchModule()',
name: 'shimmer.registerHooks()',
agent: true,
fn: function (agent) {
return shimmer.patchModule(agent)
return shimmer.registerHooks(agent)
}
})

suite.add({
name: 'shimmer.unpatchModule()',
name: 'shimmer.removeHooks()',
fn: function () {
return shimmer.unpatchModule()
return shimmer.removeHooks()
}
})

Expand Down
7 changes: 4 additions & 3 deletions test/lib/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Benchmark {
const samples = this.samples
return (this.processedSamples = Object.keys(samples).reduce((acc, sampleName) => {
try {
acc[sampleName] = new BenchmarkStats(samples[sampleName])
acc[sampleName] = new BenchmarkStats(samples[sampleName], this.name, sampleName)
return acc
} catch (e) {
/* eslint-disable no-console */
Expand Down Expand Up @@ -152,9 +152,10 @@ class Benchmark {
}

class BenchmarkStats {
constructor(samples) {
constructor(samples, testName, sampleName) {
if (samples.length < 1) {
throw new Error('BenchmarkStats requires additional samples')
console.log(`BenchmarkStats for ${testName} has no samples. SampleName: ${sampleName}`)
throw new Error('BenchmarkStats requires more than zero samples')
}

let sortedSamples = samples.slice().sort((a, b) => a - b)
Expand Down

0 comments on commit 1528d68

Please sign in to comment.