Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Updated shimmer method in benchmark tests #2281

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading