Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2020-10-26 18:57:04 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2020-11-04 05:40:14 +0300
commitdbcadf005e515e259f061266587b098549fa0c60 (patch)
treef6b6535f4045ab65d1ee4ca00d11d19c0383a26a /benchmark
parent38c15691eb8070b19a04dc572ac09dcb9155f3f1 (diff)
benchmark: make the benchmark tool work with Node 10
Avoid using class fields in the benchmark tools since they are not available in Node 10. This can be reverted when Node 10 reaches EOL. PR-URL: https://github.com/nodejs/node/pull/35817 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Mary Marchini <oss@mmarchini.me>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/common.js40
1 files changed, 20 insertions, 20 deletions
diff --git a/benchmark/common.js b/benchmark/common.js
index 701a8d6c34f..bdccd6605f3 100644
--- a/benchmark/common.js
+++ b/benchmark/common.js
@@ -4,24 +4,24 @@ const child_process = require('child_process');
const http_benchmarkers = require('./_http-benchmarkers.js');
class Benchmark {
- // Used to make sure a benchmark only start a timer once
- #started = false;
+ constructor(fn, configs, options = {}) {
+ // Used to make sure a benchmark only start a timer once
+ this._started = false;
- // Indicate that the benchmark ended
- #ended = false;
+ // Indicate that the benchmark ended
+ this._ended = false;
- // Holds process.hrtime value
- #time = [0, 0];
+ // Holds process.hrtime value
+ this._time = [0, 0];
- // Use the file name as the name of the benchmark
- name = require.main.filename.slice(__dirname.length + 1);
+ // Use the file name as the name of the benchmark
+ this.name = require.main.filename.slice(__dirname.length + 1);
- // Execution arguments i.e. flags used to run the jobs
- flags = process.env.NODE_BENCHMARK_FLAGS ?
- process.env.NODE_BENCHMARK_FLAGS.split(/\s+/) :
- [];
+ // Execution arguments i.e. flags used to run the jobs
+ this.flags = process.env.NODE_BENCHMARK_FLAGS ?
+ process.env.NODE_BENCHMARK_FLAGS.split(/\s+/) :
+ [];
- constructor(fn, configs, options = {}) {
// Parse job-specific configuration from the command line arguments
const argv = process.argv.slice(2);
const parsed_args = this._parseArgs(argv, configs, options);
@@ -214,21 +214,21 @@ class Benchmark {
}
start() {
- if (this.#started) {
+ if (this._started) {
throw new Error('Called start more than once in a single benchmark');
}
- this.#started = true;
- this.#time = process.hrtime();
+ this._started = true;
+ this._time = process.hrtime();
}
end(operations) {
// Get elapsed time now and do error checking later for accuracy.
- const elapsed = process.hrtime(this.#time);
+ const elapsed = process.hrtime(this._time);
- if (!this.#started) {
+ if (!this._started) {
throw new Error('called end without start');
}
- if (this.#ended) {
+ if (this._ended) {
throw new Error('called end multiple times');
}
if (typeof operations !== 'number') {
@@ -244,7 +244,7 @@ class Benchmark {
elapsed[1] = 1;
}
- this.#ended = true;
+ this._ended = true;
const time = elapsed[0] + elapsed[1] / 1e9;
const rate = operations / time;
this.report(rate, elapsed);