File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 12
12
13
13
import TestsUtils
14
14
15
+ let count = 10_000
16
+ let result = count / 10
17
+
15
18
@inline ( never)
16
19
public func run_DictionaryGroup( _ N: Int ) {
17
- let count = 100 * N
18
- let result = count / 10
20
+ for _ in 1 ... N {
19
21
let dict = Dictionary ( grouping: 0 ..< count, by: { $0 % 10 } )
20
22
CheckResults ( dict. count == 10 )
21
23
CheckResults ( dict [ 0 ] !. count == result)
24
+ }
22
25
}
23
26
24
27
class Box < T : Hashable > : Hashable {
@@ -39,9 +42,10 @@ class Box<T : Hashable> : Hashable {
39
42
40
43
@inline ( never)
41
44
public func run_DictionaryGroupOfObjects( _ N: Int ) {
42
- let count = 20 * N
43
- let result = count / 10
44
- let dict = Dictionary ( grouping: ( 0 ..< count ) . map { Box ( $0 ) } , by: { Box ( $0. value % 10 ) } )
45
+ let objects = ( 0 ..< count ) . map { Box ( $0 ) }
46
+ for _ in 1 ... N {
47
+ let dict = Dictionary ( grouping: objects , by: { Box ( $0. value % 10 ) } )
45
48
CheckResults ( dict. count == 10 )
46
49
CheckResults ( dict [ Box ( 0 ) ] !. count == result)
50
+ }
47
51
}
You can’t perform that action at this time.
0 commit comments