Skip to content

Commit c39085e

Browse files
committed
benchmark: remove optimization guard
Due to lack of evidence and review requirement the avoidV8Optimization variable was removed and left the callbacks as no-ops. Signed-off-by: Luan Muniz <luan@luanmuniz.com.br>
1 parent d09c413 commit c39085e

2 files changed

Lines changed: 19 additions & 34 deletions

File tree

benchmark/test_runner/hooks.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,25 @@ const hookList = {
2727
afterEach: afterEach,
2828
};
2929

30-
function run(loopAmount, avoidV8Optimization, hookFn) {
30+
const noop = () => {};
31+
32+
function run(loopAmount, hookFn) {
3133
for (let i = 0; i < loopAmount; i++) {
3234
describe(`${i}`, () => {
33-
hookFn(() => {
34-
avoidV8Optimization = i;
35-
});
36-
37-
it(`${i}`, () => {
38-
avoidV8Optimization = i;
39-
});
35+
hookFn(noop);
36+
it(`${i}`, noop);
4037
});
4138
}
4239

4340
return finished(reporter);
4441
}
4542

4643
function main(params) {
47-
// eslint-disable-next-line prefer-const
48-
let avoidV8Optimization = 0;
4944
const hookFn = hookList[params.hook];
5045

5146
bench.start();
5247

53-
run(params.n, avoidV8Optimization, hookFn).then(() => {
48+
run(params.n, hookFn).then(() => {
5449
bench.end(params.n);
5550
});
5651
}

benchmark/test_runner/test-options.js

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ const bench = common.createBenchmark(main, {
2323
flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'],
2424
});
2525

26+
const noop = () => {};
27+
2628
const allTests = {
27-
'none': (loopAmount, avoidV8Optimization) => {
29+
'none': (loopAmount) => {
2830
for (let i = 0; i < loopAmount; i++) {
29-
it(`${i}`, () => {
30-
avoidV8Optimization = i;
31-
});
31+
it(`${i}`, noop);
3232
}
3333

3434
return finished(reporter);
@@ -51,58 +51,50 @@ const allTests = {
5151

5252
return finished(reporter);
5353
},
54-
'skip-method': (loopAmount, avoidV8Optimization) => {
54+
'skip-method': (loopAmount) => {
5555
for (let i = 0; i < loopAmount; i++) {
5656
it(`${i}`, (t) => {
57-
avoidV8Optimization = i;
5857
t.skip();
5958
});
6059
}
6160

6261
return finished(reporter);
6362
},
64-
'skip-method-with-message': (loopAmount, avoidV8Optimization) => {
63+
'skip-method-with-message': (loopAmount) => {
6564
for (let i = 0; i < loopAmount; i++) {
6665
it(`${i}`, (t) => {
67-
avoidV8Optimization = i;
6866
t.skip('skip reason');
6967
});
7068
}
7169

7270
return finished(reporter);
7371
},
74-
'todo': (loopAmount, avoidV8Optimization) => {
72+
'todo': (loopAmount) => {
7573
for (let i = 0; i < loopAmount; i++) {
76-
it(`${i}`, { todo: true }, () => {
77-
avoidV8Optimization = i;
78-
});
74+
it(`${i}`, { todo: true }, noop);
7975
}
8076

8177
return finished(reporter);
8278
},
83-
'todo-with-message': (loopAmount, avoidV8Optimization) => {
79+
'todo-with-message': (loopAmount) => {
8480
for (let i = 0; i < loopAmount; i++) {
85-
it(`${i}`, { todo: 'todo reason' }, () => {
86-
avoidV8Optimization = i;
87-
});
81+
it(`${i}`, { todo: 'todo reason' }, noop);
8882
}
8983

9084
return finished(reporter);
9185
},
92-
'todo-method': (loopAmount, avoidV8Optimization) => {
86+
'todo-method': (loopAmount) => {
9387
for (let i = 0; i < loopAmount; i++) {
9488
it(`${i}`, (t) => {
95-
avoidV8Optimization = i;
9689
t.todo();
9790
});
9891
}
9992

10093
return finished(reporter);
10194
},
102-
'todo-method-with-message': (loopAmount, avoidV8Optimization) => {
95+
'todo-method-with-message': (loopAmount) => {
10396
for (let i = 0; i < loopAmount; i++) {
10497
it(`${i}`, (t) => {
105-
avoidV8Optimization = i;
10698
t.todo('todo reason');
10799
});
108100
}
@@ -112,13 +104,11 @@ const allTests = {
112104
};
113105

114106
function main({ n, option }) {
115-
// eslint-disable-next-line prefer-const
116-
let avoidV8Optimization = 0;
117107
const runOption = allTests[option];
118108

119109
bench.start();
120110

121-
runOption(n, avoidV8Optimization).then(() => {
111+
runOption(n).then(() => {
122112
bench.end(n);
123113
});
124114
}

0 commit comments

Comments
 (0)