@@ -22,26 +22,26 @@ import Foundation
22
22
public let CharacterPropertiesFetch = BenchmarkInfo (
23
23
name: " CharacterPropertiesFetch " ,
24
24
runFunction: run_CharacterPropertiesFetch,
25
- tags: [ . validation, . api, . String] )
25
+ tags: [ . validation, . api, . String] ,
26
+ setUpFunction: { blackHole ( workload) } )
26
27
27
28
public let CharacterPropertiesStashed = BenchmarkInfo (
28
29
name: " CharacterPropertiesStashed " ,
29
30
runFunction: run_CharacterPropertiesStashed,
30
31
tags: [ . validation, . api, . String] ,
31
- setUpFunction: { run_CharacterPropertiesStashed ( 1 ) } ,
32
- tearDownFunction: nil )
32
+ setUpFunction: { setupStash ( ) } )
33
33
34
34
public let CharacterPropertiesStashedMemo = BenchmarkInfo (
35
35
name: " CharacterPropertiesStashedMemo " ,
36
36
runFunction: run_CharacterPropertiesStashedMemo,
37
- tags: [ . validation, . api, . String] )
37
+ tags: [ . validation, . api, . String] ,
38
+ setUpFunction: { setupMemo ( ) } )
38
39
39
40
public let CharacterPropertiesPrecomputed = BenchmarkInfo (
40
41
name: " CharacterPropertiesPrecomputed " ,
41
42
runFunction: run_CharacterPropertiesPrecomputed,
42
43
tags: [ . validation, . api, . String] ,
43
- setUpFunction: { run_CharacterPropertiesPrecomputed ( 1 ) } ,
44
- tearDownFunction: nil )
44
+ setUpFunction: { setupPrecomputed ( ) } )
45
45
46
46
extension Character {
47
47
var firstScalar : UnicodeScalar { return unicodeScalars. first! }
@@ -122,6 +122,20 @@ func isCapitalizedStashed(_ c: Character) -> Bool {
122
122
return capitalizedLetters. contains ( c. firstScalar)
123
123
}
124
124
125
+ func setupStash( ) {
126
+ blackHole ( workload)
127
+ blackHole ( controlCharacters)
128
+ blackHole ( alphanumerics)
129
+ blackHole ( lowercaseLetters)
130
+ blackHole ( punctuationCharacters)
131
+ blackHole ( whitespaces)
132
+ blackHole ( letters)
133
+ blackHole ( uppercaseLetters)
134
+ blackHole ( decimalDigits)
135
+ blackHole ( newlines)
136
+ blackHole ( capitalizedLetters)
137
+ }
138
+
125
139
// Memoize the stashed set
126
140
var controlCharactersMemo = Set < UInt32 > ( )
127
141
func isControlStashedMemo( _ c: Character ) -> Bool {
@@ -224,6 +238,20 @@ func isCapitalizedStashedMemo(_ c: Character) -> Bool {
224
238
return false
225
239
}
226
240
241
+ func setupMemo( ) {
242
+ blackHole ( workload)
243
+ blackHole ( controlCharactersMemo)
244
+ blackHole ( alphanumericsMemo)
245
+ blackHole ( lowercaseLettersMemo)
246
+ blackHole ( punctuationCharactersMemo)
247
+ blackHole ( whitespacesMemo)
248
+ blackHole ( lettersMemo)
249
+ blackHole ( uppercaseLettersMemo)
250
+ blackHole ( decimalDigitsMemo)
251
+ blackHole ( newlinesMemo)
252
+ blackHole ( capitalizedLettersMemo)
253
+ }
254
+
227
255
// Precompute whole scalar set
228
256
var controlCharactersPrecomputed : Set < UInt32 > = {
229
257
var result = Set < UInt32 > ( )
@@ -356,6 +384,20 @@ func isCapitalizedPrecomputed(_ c: Character) -> Bool {
356
384
return capitalizedLettersPrecomputed. contains ( c. firstScalar. value)
357
385
}
358
386
387
+ func setupPrecomputed( ) {
388
+ blackHole ( workload)
389
+ blackHole ( controlCharactersPrecomputed)
390
+ blackHole ( alphanumericsPrecomputed)
391
+ blackHole ( lowercaseLettersPrecomputed)
392
+ blackHole ( punctuationCharactersPrecomputed)
393
+ blackHole ( whitespacesPrecomputed)
394
+ blackHole ( lettersPrecomputed)
395
+ blackHole ( uppercaseLettersPrecomputed)
396
+ blackHole ( decimalDigitsPrecomputed)
397
+ blackHole ( newlinesPrecomputed)
398
+ blackHole ( capitalizedLettersPrecomputed)
399
+ }
400
+
359
401
// Compute on the fly
360
402
//
361
403
// TODO: If UnicodeScalars ever exposes category, etc., implement the others!
0 commit comments