Skip to content

Commit 35240ca

Browse files
Trottaddaleax
authored andcommittedJan 23, 2019
test: refactor min() in test-hash-seed
Replace min() function with Math.min(...). PR-URL: #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>
1 parent 779ce29 commit 35240ca

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed
 

‎test/fixtures/guess-hash-seed.js

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
'use strict';
2-
function min(arr) {
3-
let res = arr[0];
4-
for (let i = 1; i < arr.length; i++) {
5-
const val = arr[i];
6-
if (val < res)
7-
res = val;
8-
}
9-
return res;
10-
}
112
function run_repeated(n, fn) {
123
const res = [];
134
for (let i = 0; i < n; i++) res.push(fn());
@@ -118,11 +109,11 @@ let tester_set_treshold;
118109

119110
// calibrate Set access times for accessing the full bucket / an empty bucket
120111
const pos_time =
121-
min(run_repeated(10000, time_set_lookup.bind(null, tester_set,
122-
positive_test_value)));
112+
Math.min(...run_repeated(10000, time_set_lookup.bind(null, tester_set,
113+
positive_test_value)));
123114
const neg_time =
124-
min(run_repeated(10000, time_set_lookup.bind(null, tester_set,
125-
negative_test_value)));
115+
Math.min(...run_repeated(10000, time_set_lookup.bind(null, tester_set,
116+
negative_test_value)));
126117
tester_set_treshold = (pos_time + neg_time) / 2;
127118
// console.log(`pos_time: ${pos_time}, neg_time: ${neg_time},`,
128119
// `threshold: ${tester_set_treshold}`);

0 commit comments

Comments
 (0)