test: refactor min() in test-hash-seed

Replace min() function with Math.min(...).

PR-URL: https://github.com/nodejs/node/pull/25522
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
This commit is contained in:
Rich Trott 2019-01-15 10:04:34 -08:00
parent 5fdd554730
commit eed096ea2e

View File

@ -1,13 +1,4 @@
'use strict';
function min(arr) {
let res = arr[0];
for (let i = 1; i < arr.length; i++) {
const val = arr[i];
if (val < res)
res = val;
}
return res;
}
function run_repeated(n, fn) {
const res = [];
for (let i = 0; i < n; i++) res.push(fn());
@ -118,11 +109,11 @@ let tester_set_treshold;
// calibrate Set access times for accessing the full bucket / an empty bucket
const pos_time =
min(run_repeated(10000, time_set_lookup.bind(null, tester_set,
positive_test_value)));
Math.min(...run_repeated(10000, time_set_lookup.bind(null, tester_set,
positive_test_value)));
const neg_time =
min(run_repeated(10000, time_set_lookup.bind(null, tester_set,
negative_test_value)));
Math.min(...run_repeated(10000, time_set_lookup.bind(null, tester_set,
negative_test_value)));
tester_set_treshold = (pos_time + neg_time) / 2;
// console.log(`pos_time: ${pos_time}, neg_time: ${neg_time},`,
// `threshold: ${tester_set_treshold}`);