Tests: Speed up CopyOnWriteHash(Map|Set)Tests
These tests create artificial hash collisions in order to make sure that they can be resolved correctly. But this also makes the tests very slow if there are too many collisions because insertions/deletions become linear in such cases. The tests have been modified to not do too many iterations when collisions are likely. Close #10442
This commit is contained in:
parent
1d56502e52
commit
37f3351b58
|
@ -55,9 +55,11 @@ public class CopyOnWriteHashMapTests extends ElasticsearchTestCase {
|
|||
public void testDuel() {
|
||||
final int iters = scaledRandomIntBetween(2, 5);
|
||||
for (int iter = 0; iter < iters; ++iter) {
|
||||
final int numOps = randomInt(5000);
|
||||
final int valueBits = randomIntBetween(1, 30);
|
||||
final int hashBits = randomInt(valueBits);
|
||||
// we compute the total number of ops based on the bits of the hash
|
||||
// since the test is much heavier when few bits are used for the hash
|
||||
final int numOps = randomInt(10 + hashBits * 100);
|
||||
|
||||
Map<O, Integer> ref = new HashMap<>();
|
||||
CopyOnWriteHashMap<O, Integer> map = new CopyOnWriteHashMap<>();
|
||||
|
|
|
@ -55,9 +55,11 @@ public class CopyOnWriteHashSetTests extends ElasticsearchTestCase {
|
|||
public void testDuel() {
|
||||
final int iters = scaledRandomIntBetween(2, 5);
|
||||
for (int iter = 0; iter < iters; ++iter) {
|
||||
final int numOps = randomInt(5000);
|
||||
final int valueBits = randomIntBetween(1, 30);
|
||||
final int hashBits = randomInt(valueBits);
|
||||
// we compute the total number of ops based on the bits of the hash
|
||||
// since the test is much heavier when few bits are used for the hash
|
||||
final int numOps = randomInt(10 + hashBits * 100);
|
||||
|
||||
Set<O> ref = new HashSet<>();
|
||||
CopyOnWriteHashSet<O> set = new CopyOnWriteHashSet<>();
|
||||
|
|
Loading…
Reference in New Issue