Skip to content

Commit a256138

Browse files
committed
Move benchmarks over to new benchmarking tool.
addresses #690
1 parent a838790 commit a256138

4 files changed

Lines changed: 15 additions & 38 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
2727
- perf: New, more space-efficient storage engine, 20-45% faster stats recording
2828
- perf: Further improvement to key generation cost
2929
- fix: Browser compatibility for Gauge.startTimer()
30+
- ci: switch out deprecated benchmark-regression library for replacement
3031

3132
### Added
3233

benchmarks/index.js

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

3-
const createRegressionBenchmark = require('@clevernature/benchmark-regression');
4-
const { Benchmark } = require('benchmark');
3+
const Benchmark = require('faceoff').default;
54
const debug = require('debug')('benchmark');
65

76
/**
@@ -13,42 +12,18 @@ const debug = require('debug')('benchmark');
1312
* 2018, that situation is unlikely to change soon.
1413
*/
1514

16-
Benchmark.options.defer = true;
17-
Benchmark.options.onStart = event => {
18-
const benchmark = event.target;
19-
const name = benchmark.name;
20-
const original = benchmark.fn;
21-
22-
debug(`Starting '${name}'`);
23-
24-
benchmark.fn = async deferred => {
25-
try {
26-
await original();
27-
} catch (e) {
28-
console.error(e);
29-
} finally {
30-
deferred.resolve();
31-
}
32-
};
33-
};
34-
Benchmark.options.onAbort = event => {
35-
console.error(event);
36-
};
37-
Benchmark.options.onError = event => {
38-
console.error(event);
39-
};
40-
4115
const currentClient = require('..');
42-
const benchmarks = createRegressionBenchmark(
43-
{ name: 'prom-client@current', module: currentClient },
44-
['prom-client@latest'],
45-
);
16+
const benchmarks = new Benchmark({
17+
'prom-client@latest': 'prom-client@latest',
18+
'prom-client@trunk': 'git@github.com:siimon/prom-client',
19+
'prom-client@current': currentClient,
20+
});
4621

4722
benchmarks.suite('counter', require('./counter'));
4823
benchmarks.suite('gauge', require('./gauge'));
4924
benchmarks.suite('histogram', require('./histogram'));
50-
benchmarks.suite('summary', require('./summary'));
5125
benchmarks.suite('util', require('./util'));
26+
benchmarks.suite('summary', require('./summary'));
5227
benchmarks.suite('registry', require('./registry'));
5328
benchmarks.suite('cluster', require('./cluster'));
5429

benchmarks/util.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
module.exports = setupUtilSuite;
44

55
function setupUtilSuite(suite) {
6+
const skip = ['prom-client@latest', 'prom-client@trunk'];
7+
68
suite.add(
79
'hashObject',
810
(client, Util) => {
@@ -16,7 +18,7 @@ function setupUtilSuite(suite) {
1618
gateway: 'lb04',
1719
});
1820
},
19-
{ setup: findUtil },
21+
{ setup: findUtil, skip },
2022
);
2123

2224
suite.add(
@@ -32,7 +34,7 @@ function setupUtilSuite(suite) {
3234
status_code: 503,
3335
});
3436
},
35-
{ setup },
37+
{ setup, skip },
3638
);
3739

3840
suite.add(
@@ -48,7 +50,7 @@ function setupUtilSuite(suite) {
4850
status_code: 503,
4951
});
5052
},
51-
{ setup },
53+
{ setup, skip },
5254
);
5355
}
5456

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"node": "^20 || ^22 || >=24"
1313
},
1414
"scripts": {
15-
"benchmarks": "node --max-heap-size=5000 ./benchmarks/index.js",
15+
"benchmarks": "node --max-heap-size=5000 --allow-natives-syntax ./benchmarks/index.js",
1616
"test": "npm run lint && npm run check-prettier && npm run compile-typescript && npm run test-unit -- --coverage",
1717
"lint": "eslint .",
1818
"test-unit": "jest",
@@ -34,16 +34,15 @@
3434
"license": "Apache-2.0",
3535
"homepage": "https://github.com/siimon/prom-client",
3636
"devDependencies": {
37-
"@clevernature/benchmark-regression": "^1.0.0",
3837
"@eslint/js": "^9.29.0",
39-
"benchmark": "^2.1",
4038
"debug": "^4.4.1",
4139
"eslint": "^9.29.0",
4240
"eslint-config-prettier": "^10.1.5",
4341
"eslint-plugin-jsdoc": "^52.0.0",
4442
"eslint-plugin-n": "^17.20.0",
4543
"eslint-plugin-prettier": "^5.0.1",
4644
"express": "^5.1.0",
45+
"faceoff": "^0.9.0",
4746
"globals": "^16.2.0",
4847
"husky": "^9.0.0",
4948
"jest": "^30.0.2",

0 commit comments

Comments
 (0)