@@ -14,38 +14,65 @@ import TestsUtils
14
14
15
15
public let benchmarks : [ BenchmarkInfo ] = [
16
16
BenchmarkInfo (
17
- name: " StringDistance.characters " ,
17
+ name: " StringDistance.characters.mixed " ,
18
18
runFunction: { n in
19
- run_characters ( string: sampleString , ranges: sampleRanges , n: n)
19
+ run_characters ( string: mixedString , ranges: mixedRanges , n: n)
20
20
} ,
21
21
tags: [ . api, . String] ,
22
- setUpFunction: { _ = sampleRanges } ) ,
22
+ setUpFunction: { blackHole ( mixedRanges ) } ) ,
23
23
BenchmarkInfo (
24
- name: " StringDistance.scalars " ,
24
+ name: " StringDistance.scalars.mixed " ,
25
25
runFunction: { n in
26
- run_scalars ( string: sampleString , ranges: sampleRanges , n: n)
26
+ run_scalars ( string: mixedString , ranges: mixedRanges , n: n)
27
27
} ,
28
28
tags: [ . api, . String] ,
29
- setUpFunction: { _ = sampleRanges } ) ,
29
+ setUpFunction: { blackHole ( mixedRanges ) } ) ,
30
30
BenchmarkInfo (
31
- name: " StringDistance.utf16 " ,
31
+ name: " StringDistance.utf16.mixed " ,
32
32
runFunction: { n in
33
- run_utf16 ( string: sampleString , ranges: sampleRanges , n: n)
33
+ run_utf16 ( string: mixedString , ranges: mixedRanges , n: n)
34
34
} ,
35
35
tags: [ . api, . String] ,
36
- setUpFunction: { _ = sampleRanges } ) ,
36
+ setUpFunction: { blackHole ( mixedRanges ) } ) ,
37
37
BenchmarkInfo (
38
- name: " StringDistance.utf8 " ,
38
+ name: " StringDistance.utf8.mixed " ,
39
39
runFunction: { n in
40
- run_utf8 ( string: sampleString , ranges: sampleRanges , n: n)
40
+ run_utf8 ( string: mixedString , ranges: mixedRanges , n: n)
41
41
} ,
42
42
tags: [ . api, . String] ,
43
- setUpFunction: { _ = sampleRanges } ) ,
43
+ setUpFunction: { blackHole ( mixedRanges) } ) ,
44
+ BenchmarkInfo (
45
+ name: " StringDistance.characters.ascii " ,
46
+ runFunction: { n in
47
+ run_characters ( string: asciiString, ranges: asciiRanges, n: n)
48
+ } ,
49
+ tags: [ . api, . String] ,
50
+ setUpFunction: { blackHole ( asciiRanges) } ) ,
51
+ BenchmarkInfo (
52
+ name: " StringDistance.scalars.ascii " ,
53
+ runFunction: { n in
54
+ run_scalars ( string: asciiString, ranges: asciiRanges, n: n)
55
+ } ,
56
+ tags: [ . api, . String] ,
57
+ setUpFunction: { blackHole ( asciiRanges) } ) ,
58
+ BenchmarkInfo (
59
+ name: " StringDistance.utf16.ascii " ,
60
+ runFunction: { n in
61
+ run_utf16 ( string: asciiString, ranges: asciiRanges, n: n)
62
+ } ,
63
+ tags: [ . api, . String] ,
64
+ setUpFunction: { blackHole ( asciiRanges) } ) ,
65
+ BenchmarkInfo (
66
+ name: " StringDistance.utf8.ascii " ,
67
+ runFunction: { n in
68
+ run_utf8 ( string: asciiString, ranges: asciiRanges, n: n)
69
+ } ,
70
+ tags: [ . api, . String] ,
71
+ setUpFunction: { blackHole ( asciiRanges) } ) ,
44
72
]
45
73
46
74
47
- let sampleString =
48
- #"""
75
+ let mixedString = #"""
49
76
The powerful programming language that is also easy to learn.
50
77
손쉽게 학습할 수 있는 강력한 프로그래밍 언어.
51
78
🪙 A 🥞 short 🍰 piece 🫘 of 🌰 text 👨👨👧👧 with 👨👩👦 some 🚶🏽 emoji 🇺🇸🇨🇦 characters 🧈
@@ -62,17 +89,42 @@ let sampleString =
62
89
e̶̢͕̦̜͔̘̘̝͈̪̖̺̥̺̹͉͎͈̫̯̯̻͑͑̿̽͂̀̽͋́̎̈́̈̿͆̿̒̈́̽̔̇͐͛̀̓͆̏̾̀̌̈́̆̽̕ͅ
63
90
"""#
64
91
65
- let sampleRanges = (
66
- generateRanges ( for: sampleString, by: 1 )
67
- + generateRanges( for: sampleString, by: 2 )
68
- + generateRanges( for: sampleString, by: 4 )
69
- + generateRanges( for: sampleString, by: 8 )
70
- + generateRanges( for: sampleString, by: 16 )
71
- + generateRanges( for: sampleString, by: 32 )
72
- + generateRanges( for: sampleString, by: 64 )
73
- + generateRanges( for: sampleString, by: 128 )
74
- + generateRanges( for: sampleString, by: 256 )
75
- + generateRanges( for: sampleString, by: 512 ) )
92
+ let mixedRanges = (
93
+ generateRanges ( for: mixedString, by: 1 )
94
+ + generateRanges( for: mixedString, by: 2 )
95
+ + generateRanges( for: mixedString, by: 4 )
96
+ + generateRanges( for: mixedString, by: 8 )
97
+ + generateRanges( for: mixedString, by: 16 )
98
+ + generateRanges( for: mixedString, by: 32 )
99
+ + generateRanges( for: mixedString, by: 64 )
100
+ + generateRanges( for: mixedString, by: 128 )
101
+ + generateRanges( for: mixedString, by: 256 )
102
+ + generateRanges( for: mixedString, by: 512 ) )
103
+
104
+ let asciiString = #"""
105
+ Swift is a high-performance system programming language. It has a clean
106
+ and modern syntax, offers seamless access to existing C and Objective-C code
107
+ and frameworks, and is memory safe by default.
108
+
109
+ Although inspired by Objective-C and many other languages, Swift is not itself
110
+ a C-derived language. As a complete and independent language, Swift packages
111
+ core features like flow control, data structures, and functions, with
112
+ high-level constructs like objects, protocols, closures, and generics. Swift
113
+ embraces modules, eliminating the need for headers and the code duplication
114
+ they entail.
115
+ """#
116
+
117
+ let asciiRanges = (
118
+ generateRanges ( for: asciiString, by: 1 )
119
+ + generateRanges( for: asciiString, by: 2 )
120
+ + generateRanges( for: asciiString, by: 4 )
121
+ + generateRanges( for: asciiString, by: 8 )
122
+ + generateRanges( for: asciiString, by: 16 )
123
+ + generateRanges( for: asciiString, by: 32 )
124
+ + generateRanges( for: asciiString, by: 64 )
125
+ + generateRanges( for: asciiString, by: 128 )
126
+ + generateRanges( for: asciiString, by: 256 )
127
+ + generateRanges( for: asciiString, by: 512 ) )
76
128
77
129
func generateRanges( for string: String , by step: Int ) -> [ Range < String . Index > ] {
78
130
var remaining = step
0 commit comments