@@ -16,14 +16,6 @@ public let StringInterpolation = BenchmarkInfo(
16
16
name: " StringInterpolation " ,
17
17
runFunction: run_StringInterpolation,
18
18
tags: [ . validation, . api, . String] )
19
- public let StringInterpolationSmall = BenchmarkInfo (
20
- name: " StringInterpolationSmall " ,
21
- runFunction: run_StringInterpolationSmall,
22
- tags: [ . validation, . api, . String] )
23
- public let StringInterpolationManySmallSegments = BenchmarkInfo (
24
- name: " StringInterpolationManySmallSegments " ,
25
- runFunction: run_StringInterpolationManySmallSegments,
26
- tags: [ . validation, . api, . String] )
27
19
28
20
class RefTypePrintable : CustomStringConvertible {
29
21
var description : String {
@@ -41,66 +33,15 @@ public func run_StringInterpolation(_ N: Int) {
41
33
for _ in 1 ... 100 * N {
42
34
var result = 0
43
35
for _ in 1 ... reps {
44
- let s : String = getString (
45
- " \( anInt) abcdefdhijklmn \( aRefCountedObject) abcdefdhijklmn \u{01} " )
36
+ let s = " \( anInt) abcdefdhijklmn \( aRefCountedObject) abcdefdhijklmn \u{01} "
46
37
let utf16 = s. utf16
47
38
48
39
// FIXME: if String is not stored as UTF-16 on this platform, then the
49
40
// following operation has a non-trivial cost and needs to be replaced
50
41
// with an operation on the native storage type.
51
- result = result &+ Int ( utf16. last!)
52
- blackHole ( s)
53
- }
54
- CheckResults ( result == refResult)
55
- }
56
- }
57
-
58
- @inline ( never)
59
- public func run_StringInterpolationSmall( _ N: Int ) {
60
- let reps = 100
61
- let refResult = reps
62
- let anInt : Int64 = 0x42
63
-
64
- for _ in 1 ... 100 * N {
65
- var result = 0
66
- for _ in 1 ... reps {
67
- let s : String = getString (
68
- " \( getString ( " int " ) ) : \( anInt) \( getString ( " abc " ) ) \u{01} " )
69
- result = result &+ Int ( s. utf8. last!)
70
- blackHole ( s)
42
+ result = result &+ Int ( utf16 [ utf16. index ( before: utf16. endIndex) ] )
71
43
}
72
44
CheckResults ( result == refResult)
73
45
}
74
46
}
75
47
76
- @inline ( never)
77
- public func run_StringInterpolationManySmallSegments( _ N: Int ) {
78
- let numHex : UInt = min ( UInt ( N) , 0x0FFF_FFFF_FFFF_FFFF )
79
- let numOct : UInt = min ( UInt ( N) , 0x0000_03FF_FFFF_FFFF )
80
- let numBin : UInt = min ( UInt ( N) , 0x7FFF )
81
- let segments = [
82
- " abc " ,
83
- String ( numHex, radix: 16 ) ,
84
- " 0123456789 " ,
85
- String ( Double . pi/ 2 ) ,
86
- " *barely* small! " ,
87
- String ( numOct, radix: 8 ) ,
88
- " " ,
89
- String ( numBin, radix: 2 ) ,
90
- ]
91
- assert ( segments. count == 8 )
92
-
93
- func getSegment( _ i: Int ) -> String {
94
- return getString ( segments [ i] )
95
- }
96
-
97
- let reps = 100
98
- for _ in 1 ... 100 * N {
99
- for _ in 1 ... reps {
100
- blackHole ( """
101
- \( getSegment ( 0 ) ) \( getSegment ( 1 ) ) / \( getSegment ( 2 ) ) _ \( getSegment ( 3 ) )
102
- \( getSegment ( 4 ) ) \( getSegment ( 5 ) ) , \( getSegment ( 6 ) ) ~~ \( getSegment ( 7 ) )
103
- """ )
104
- }
105
- }
106
- }
0 commit comments