1
1
package com .trivago .fastutilconcurrentwrapper .intkey ;
2
2
3
3
import com .trivago .fastutilconcurrentwrapper .PrimitiveConcurrentMap ;
4
- import com .trivago .fastutilconcurrentwrapper .PrimitiveKeyMap ;
4
+ import com .trivago .fastutilconcurrentwrapper .util . CFUtil ;
5
5
import org .junit .jupiter .api .Disabled ;
6
6
import org .junit .jupiter .api .Test ;
7
7
12
12
class PrimitiveConcurrentMapTest {
13
13
@ Test
14
14
void _hashInt () {
15
- assertEquals (50_880 , PrimitiveKeyMap .bucket (Integer .MIN_VALUE , 100_000 ));
16
- assertEquals (47_470 , PrimitiveKeyMap .bucket (-Integer .MAX_VALUE , 100_000 ));
17
- assertEquals (74_300 , PrimitiveKeyMap .bucket (-100_000 , 100_000 ));
18
- assertEquals (56_431 , PrimitiveKeyMap .bucket (-1 , 100_000 ));
19
- assertEquals (0 , PrimitiveKeyMap .bucket (0 , 100_000 ));
20
- assertEquals (3_410 , PrimitiveKeyMap .bucket (1 , 100_000 ));
21
- assertEquals (82_299 , PrimitiveKeyMap .bucket (100_000 , 100_000 ));
22
- assertEquals (59_985 , PrimitiveKeyMap .bucket (Integer .MAX_VALUE , 100_000 ));
15
+ assertEquals (50_880 , CFUtil .bucket (Integer .MIN_VALUE , 100_000 ));
16
+ assertEquals (47_470 , CFUtil .bucket (-Integer .MAX_VALUE , 100_000 ));
17
+ assertEquals (74_300 , CFUtil .bucket (-100_000 , 100_000 ));
18
+ assertEquals (56_431 , CFUtil .bucket (-1 , 100_000 ));
19
+ assertEquals (0 , CFUtil .bucket (0 , 100_000 ));
20
+ assertEquals (3_410 , CFUtil .bucket (1 , 100_000 ));
21
+ assertEquals (82_299 , CFUtil .bucket (100_000 , 100_000 ));
22
+ assertEquals (59_985 , CFUtil .bucket (Integer .MAX_VALUE , 100_000 ));
23
23
}
24
24
25
25
@ Test
26
26
void _hashLong () {
27
- assertEquals (50_880 , PrimitiveKeyMap .bucket (Long .MIN_VALUE , 100_000 ));
28
- assertEquals (50_880 , PrimitiveKeyMap .bucket (Integer .MIN_VALUE & 0xFFFFFFFFL , 100_000 ));
29
- assertEquals (59_985 , PrimitiveKeyMap .bucket ((long ) Integer .MIN_VALUE , 100_000 ));
30
- assertEquals (47_470 , PrimitiveKeyMap .bucket (-Integer .MAX_VALUE & 0xFFFFFFFFL , 100_000 ));
31
- assertEquals (96_447 , PrimitiveKeyMap .bucket ((long ) -Integer .MAX_VALUE , 100_000 ));
32
- assertEquals (16_093 , PrimitiveKeyMap .bucket (-100_000L , 100_000 ));
33
- assertEquals (0 , PrimitiveKeyMap .bucket (-1L , 100_000 ));
34
- assertEquals (0 , PrimitiveKeyMap .bucket (0L , 100_000 ));
35
- assertEquals (3_410 , PrimitiveKeyMap .bucket (1L , 100_000 ));
36
- assertEquals (82_299 , PrimitiveKeyMap .bucket (100_000L , 100_000 ));
37
- assertEquals (59_985 , PrimitiveKeyMap .bucket ((long ) Integer .MAX_VALUE , 100_000 ));
38
- assertEquals (50_880 , PrimitiveKeyMap .bucket (Long .MAX_VALUE , 100_000 ));
27
+ assertEquals (50_880 , CFUtil .bucket (Long .MIN_VALUE , 100_000 ));
28
+ assertEquals (50_880 , CFUtil .bucket (Integer .MIN_VALUE & 0xFFFFFFFFL , 100_000 ));
29
+ assertEquals (59_985 , CFUtil .bucket ((long ) Integer .MIN_VALUE , 100_000 ));
30
+ assertEquals (47_470 , CFUtil .bucket (-Integer .MAX_VALUE & 0xFFFFFFFFL , 100_000 ));
31
+ assertEquals (96_447 , CFUtil .bucket ((long ) -Integer .MAX_VALUE , 100_000 ));
32
+ assertEquals (16_093 , CFUtil .bucket (-100_000L , 100_000 ));
33
+ assertEquals (0 , CFUtil .bucket (-1L , 100_000 ));
34
+ assertEquals (0 , CFUtil .bucket (0L , 100_000 ));
35
+ assertEquals (3_410 , CFUtil .bucket (1L , 100_000 ));
36
+ assertEquals (82_299 , CFUtil .bucket (100_000L , 100_000 ));
37
+ assertEquals (59_985 , CFUtil .bucket ((long ) Integer .MAX_VALUE , 100_000 ));
38
+ assertEquals (50_880 , CFUtil .bucket (Long .MAX_VALUE , 100_000 ));
39
39
}
40
40
41
41
@ Test @ Disabled ("Total checks: 38510819404, time: 8551,564, op/sec: 189_126_936" )
42
42
void longsAreSame () {
43
43
long total = 0 , t = System .nanoTime ();
44
44
for (long i = Long .MIN_VALUE , max = Long .MAX_VALUE - 479001599 -9 ; i < max ; i += 479001599 ){
45
- assertEquals (PrimitiveKeyMap .bucket (Long .valueOf (i ), 1_000_000 ), PrimitiveKeyMap .bucket (i , 1_000_000 ));
45
+ assertEquals (CFUtil .bucket (Long .valueOf (i ), 1_000_000 ), CFUtil .bucket (i , 1_000_000 ));
46
46
total ++;
47
47
}
48
48
t = System .nanoTime () - t ;
@@ -51,26 +51,26 @@ void longsAreSame () {
51
51
52
52
@ Test
53
53
void _hashObj () {
54
- assertEquals (0 , PrimitiveKeyMap .bucket (null , 100_000 ));
54
+ assertEquals (0 , CFUtil .bucket (null , 100_000 ));
55
55
56
- assertEquals (50_880 , PrimitiveKeyMap .bucket (Long .valueOf (Long .MIN_VALUE ), 100_000 ));
57
- assertEquals (50_880 , PrimitiveKeyMap .bucket (Long .valueOf (Integer .MIN_VALUE & 0xFFFFFFFFL ), 100_000 ));
58
- assertEquals (59_985 , PrimitiveKeyMap .bucket (Long .valueOf (Integer .MIN_VALUE ), 100_000 ));
59
- assertEquals (47_470 , PrimitiveKeyMap .bucket (Long .valueOf (-Integer .MAX_VALUE & 0xFFFFFFFFL ), 100_000 ));
60
- assertEquals (96_447 , PrimitiveKeyMap .bucket (Long .valueOf (-Integer .MAX_VALUE ), 100_000 ));
61
- assertEquals (16_093 , PrimitiveKeyMap .bucket (Long .valueOf (-100_000L ), 100_000 ));
62
- assertEquals (0 , PrimitiveKeyMap .bucket (Long .valueOf (-1L ), 100_000 ));
63
- assertEquals (0 , PrimitiveKeyMap .bucket (Long .valueOf (0L ), 100_000 ));
64
- assertEquals (3_410 , PrimitiveKeyMap .bucket (Long .valueOf (1L ), 100_000 ));
65
- assertEquals (82_299 , PrimitiveKeyMap .bucket (Long .valueOf (100_000L ), 100_000 ));
66
- assertEquals (59_985 , PrimitiveKeyMap .bucket (Long .valueOf (Integer .MAX_VALUE ), 100_000 ));
67
- assertEquals (50_880 , PrimitiveKeyMap .bucket (Long .valueOf (Long .MAX_VALUE ), 100_000 ));
56
+ assertEquals (50_880 , CFUtil .bucket (Long .valueOf (Long .MIN_VALUE ), 100_000 ));
57
+ assertEquals (50_880 , CFUtil .bucket (Long .valueOf (Integer .MIN_VALUE & 0xFFFFFFFFL ), 100_000 ));
58
+ assertEquals (59_985 , CFUtil .bucket (Long .valueOf (Integer .MIN_VALUE ), 100_000 ));
59
+ assertEquals (47_470 , CFUtil .bucket (Long .valueOf (-Integer .MAX_VALUE & 0xFFFFFFFFL ), 100_000 ));
60
+ assertEquals (96_447 , CFUtil .bucket (Long .valueOf (-Integer .MAX_VALUE ), 100_000 ));
61
+ assertEquals (16_093 , CFUtil .bucket (Long .valueOf (-100_000L ), 100_000 ));
62
+ assertEquals (0 , CFUtil .bucket (Long .valueOf (-1L ), 100_000 ));
63
+ assertEquals (0 , CFUtil .bucket (Long .valueOf (0L ), 100_000 ));
64
+ assertEquals (3_410 , CFUtil .bucket (Long .valueOf (1L ), 100_000 ));
65
+ assertEquals (82_299 , CFUtil .bucket (Long .valueOf (100_000L ), 100_000 ));
66
+ assertEquals (59_985 , CFUtil .bucket (Long .valueOf (Integer .MAX_VALUE ), 100_000 ));
67
+ assertEquals (50_880 , CFUtil .bucket (Long .valueOf (Long .MAX_VALUE ), 100_000 ));
68
68
}
69
69
70
70
@ Test
71
71
void buildLongKey () {
72
- assertEquals (0 , PrimitiveKeyMap .compoundKey (0 ,0 ));
73
- assertEquals (Integer .MIN_VALUE & 0xFFFFFFFFL , PrimitiveKeyMap .compoundKey (0 ,Integer .MIN_VALUE ));
74
- assertEquals (0x8000_0000_0000_0000L , PrimitiveKeyMap .compoundKey (Integer .MIN_VALUE ,0 ));
72
+ assertEquals (0 , CFUtil .compoundKey (0 ,0 ));
73
+ assertEquals (Integer .MIN_VALUE & 0xFFFFFFFFL , CFUtil .compoundKey (0 ,Integer .MIN_VALUE ));
74
+ assertEquals (0x8000_0000_0000_0000L , CFUtil .compoundKey (Integer .MIN_VALUE ,0 ));
75
75
}
76
76
}
0 commit comments