Skip to content

Commit

Permalink
test: refactor min() in test-hash-seed
Browse files Browse the repository at this point in the history
Replace min() function with Math.min(...).

PR-URL: nodejs#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>
  • Loading branch information
Trott committed Jan 18, 2019
1 parent 5fdd554 commit eed096e
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions test/fixtures/guess-hash-seed.js
Original file line number Diff line number Diff line change
@@ -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());
Expand Down Expand Up @@ -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}`);
Expand Down

0 comments on commit eed096e

Please sign in to comment.