1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
|
//===--- StringComparison.swift -------------------------------------*- swift -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
% # Ignore the following warning. This _is_ the correct file to edit.
////////////////////////////////////////////////////////////////////////////////
// WARNING: This file is manually generated from .gyb template and should not
// be directly modified. Instead, make changes to StringComparison.swift.gyb and run
// scripts/generate_harness/generate_harness.py to regenerate this file.
////////////////////////////////////////////////////////////////////////////////
//
// Test String iteration performance over a variety of workloads, languages,
// and symbols.
//
import TestsUtils
extension String {
func lines() -> [String] {
return self.split(separator: "\n").map { String($0) }
}
}
%{
AllWorkloads = ["ascii", "latin1", "fastPrenormal", "slowerPrenormal",
"nonBMPSlowestPrenormal", "emoji", "abnormal", "zalgo",
"longSharedPrefix"]
ComparisonWorkloads = AllWorkloads
HashingWorkloads = AllWorkloads[:-1]
NormalizationWorkloads = AllWorkloads[:-1]
LegacyFactor = dict(abnormal=20, emoji=4, latin1=2, fastPrenormal=10,
slowerPrenormal=10, nonBMPSlowestPrenormal=10, zalgo=25)
def legacyFactor(name):
lf = LegacyFactor.get(name)
return (
',\n\t\tlegacyFactor: {0}'.format(lf) if lf else
'')
}%
public let benchmarks: [BenchmarkInfo] = [
% for Name in ComparisonWorkloads:
BenchmarkInfo(
name: "StringComparison_${Name}",
runFunction: run_StringComparison_${Name},
tags: [.validation, .api, .String],
setUpFunction: { blackHole(workload_${Name}) }${legacyFactor(Name)}
),
% end # ComparisonWorkloads
% for Name in HashingWorkloads:
BenchmarkInfo(
name: "StringHashing_${Name}",
runFunction: run_StringHashing_${Name},
tags: [.validation, .api, .String],
setUpFunction: { blackHole(workload_${Name}) }${legacyFactor(Name)}
),
% end # HashingWorkloads
% for Name in NormalizationWorkloads:
BenchmarkInfo(
name: "NormalizedIterator_${Name}",
runFunction: run_StringNormalization_${Name},
tags: [.validation, .String],
setUpFunction: { blackHole(workload_${Name}) }${legacyFactor(Name)}
),
% end # NormalizationWorkloads
]
% for Name in AllWorkloads:
let workload_${Name}: Workload! = Workload.${Name}
% end # AllWorkloads
%for Name in ComparisonWorkloads:
@inline(never)
public func run_StringComparison_${Name}(_ n: Int) {
let workload: Workload = workload_${Name}
let tripCount = workload.tripCount
let payload = workload.payload
for _ in 1...tripCount*n {
for s1 in payload {
for s2 in payload {
blackHole(s1 < s2)
}
}
}
}
% end # ComparisonWorkloads
%for Name in HashingWorkloads:
@inline(never)
public func run_StringHashing_${Name}(_ n: Int) {
let workload: Workload = Workload.${Name}
let tripCount = workload.tripCount
let payload = workload.payload
for _ in 1...tripCount*n {
for str in payload {
blackHole(str.hashValue)
}
}
}
% end # HashingWorkloads
%for Name in NormalizationWorkloads:
@inline(never)
public func run_StringNormalization_${Name}(_ n: Int) {
let workload: Workload = Workload.${Name}
let tripCount = workload.tripCount
let payload = workload.payload
for _ in 1...tripCount*n {
for str in payload {
str._withNFCCodeUnits { cu in
blackHole(cu)
}
}
}
}
% end # NormalizationWorkloads
struct Workload {
static let n = 100
let name: String
let payload: [String]
var scaleMultiplier: Double
init(name: String, payload: [String], scaleMultiplier: Double = 1.0) {
self.name = name
self.payload = payload
self.scaleMultiplier = scaleMultiplier
}
var tripCount: Int {
return Int(Double(Workload.n) * scaleMultiplier)
}
static let ascii = Workload(
name: "ASCII",
payload: """
woodshed
lakism
gastroperiodynia
afetal
Casearia
ramsch
Nickieben
undutifulness
decorticate
neognathic
mentionable
tetraphenol
pseudonymal
dislegitimate
Discoidea
criminative
disintegratory
executer
Cylindrosporium
complimentation
Ixiama
Araceae
silaginoid
derencephalus
Lamiidae
marrowlike
ninepin
trihemimer
semibarbarous
heresy
existence
fretless
Amiranha
handgravure
orthotropic
Susumu
teleutospore
sleazy
shapeliness
hepatotomy
exclusivism
stifler
cunning
isocyanuric
pseudepigraphy
carpetbagger
unglory
""".lines(),
scaleMultiplier: 0.25
)
static let latin1 = Workload(
name: "Latin1",
payload: """
café
résumé
caférésumé
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º
1+1=3
¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹
¡¢£¤¥¦§¨©ª«¬®
»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍ
ÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãä
åæçèéêëìíîïðñò
ÎÏÐÑÒÓÔÕÖëìíîïðñò
óôõö÷øùúûüýþÿ
123.456£=>¥
123.456
""".lines(),
scaleMultiplier: 1/2
)
static let fastPrenormal = Workload(
name: "FastPrenormal",
payload: """
ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥ
ĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸ
ĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲ
ųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆ
ƇƈƉƊƋƌƍƎƏƐƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀ
Ƈ
ǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖ
ǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑ
ȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬ
ȒȓȔȕȖȗȘșȚțȜȝȞȟȠȡȢȣȤȥȦȧȨȩȪȫȬDzdzǴǵǶǷǸǹǺǻǼǽǾǿȀȁȂȃȄȅȆȇȈȉȊȋȌȍȎȏȐȑ
ȭȮȯȰȱȲȳȴȵȶȷȸȹȺȻȼȽȾȿɀɁɂɃɄɅɆɇɈɉɊɋɌɍɎɏɐɑɒɓɔɕɖɗɘəɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰ
ɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄ
ɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃ
ʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰ
ʱʲʳʴʵʶʷʸʹʺʻʼʽʾʿˀˁ˂˃˄˅ˆˇˈˉˊˋˌˍˎˏːˑ˒˓˔˕˖˗˘˙˚˛˜˝˞˟ˠˡˢˣˤ˥˦
˧˨˩˪˫ˬ˭ˮ˯˰˱˲˳˴˵˶˷˸˹˺˻˼˽˾
""".lines(),
scaleMultiplier: 1/10
)
static let slowerPrenormal = Workload(
name: "SlowerPrenormal",
payload: """
Swiftに大幅な改良が施され、
安定していてしかも
直感的に使うことができる
向けプログラミング言語になりました。
이번 업데이트에서는 강력하면서도
\u{201c}Hello\u{2010}world\u{2026}\u{201d}
平台的编程语言
功能强大且直观易用
而本次更新对其进行了全面优化
в чащах юга жил-был цитрус
\u{300c}\u{300e}今日は\u{3001}世界\u{3002}\u{300f}\u{300d}
но фальшивый экземпляр
""".lines(),
scaleMultiplier: 1/10
)
// static let slowestPrenormal = """
// """.lines()
static let nonBMPSlowestPrenormal = Workload(
name: "NonBMPSlowestPrenormal",
payload: """
𓀀𓀤𓁓𓁲𓃔𓃗
𓀀𓀁𓀂𓀃𓀄𓀇𓀈𓀉𓀊𓀋𓀌𓀍𓀎𓀏𓀓𓀔𓀕𓀖𓀗𓀘𓀙𓀚𓀛𓀜𓀞𓀟𓀠𓀡𓀢𓀣
𓀤𓀥𓀦𓀧𓀨𓀩𓀪𓀫𓀬𓀭
𓁡𓁢𓁣𓁤𓁥𓁦𓁧𓁨𓁩𓁫𓁬𓁭𓁮𓁯𓁰𓁱𓁲𓁳𓁴𓁵𓁶𓁷𓁸
𓁹𓁺𓁓𓁔𓁕𓁻𓁼𓁽𓁾𓁿
𓀀𓀁𓀂𓀃𓀄𓃒𓃓𓃔𓃕𓃻𓃼𓃽𓃾𓃿𓄀𓄁𓄂𓄃𓄄𓄅𓄆𓄇𓄈𓄉𓄊𓄋𓄌𓄍𓄎
𓂿𓃀𓃁𓃂𓃃𓃄𓃅
𓃘𓃙𓃚𓃛𓃠𓃡𓃢𓃣𓃦𓃧𓃨𓃩𓃬𓃭𓃮𓃯𓃰𓃲𓃳𓃴𓃵𓃶𓃷𓃸
𓃘𓃙𓃚𓃛𓃠𓃡𓃢𓃣𓃦𓃧𓃨𓃩𓃬𓃭𓃮𓃯𓃰𓃲𓃳𓃴𓃵𓃶𓃷
𓀀𓀁𓀂𓀃𓀄𓆇𓆈𓆉𓆊𓆋𓆌𓆍𓆎𓆏𓆐𓆑𓆒𓆓𓆔𓆗𓆘𓆙𓆚𓆛𓆝𓆞𓆟𓆠𓆡𓆢𓆣𓆤
𓆥𓆦𓆧𓆨𓆩𓆪𓆫𓆬𓆭𓆮𓆯𓆰𓆱𓆲𓆳𓆴𓆵𓆶𓆷𓆸𓆹𓆺𓆻
""".lines(),
scaleMultiplier: 1/10
)
static let emoji = Workload(
name: "Emoji",
payload: """
👍👩👩👧👧👨👨👦👦🇺🇸🇨🇦🇲🇽👍🏻👍🏼👍🏽👍🏾👍🏿
👍👩👩👧👧👨👨👦👦🇺🇸🇨🇦🇲🇽👍🏿👍🏻👍🏼👍🏽👍🏾
😀🧀😀😃😄😁🤣😂😅😆
😺🎃🤖👾😸😹😻😼😾😿🙀😽🙌🙏🤝👍✌🏽
☺️😊😇🙂😍😌😉🙃😘😗😙😚😛😝😜
😋🤑🤗🤓😎😒😏🤠🤡😞😔😟😕😖😣☹️🙁😫😩😤😠😑😐😶😡😯
😦😧😮😱😳😵😲😨😰😢😥
😪😓😭🤤😴🙄🤔🤥🤧🤢🤐😬😷🤒🤕😈💩👺👹👿👻💀☠️👽
""".lines(),
scaleMultiplier: 1/4
)
static let abnormal = Workload(
name: "Abnormal",
payload: """
ae\u{301}ae\u{301}ae\u{302}ae\u{303}ae\u{304}ae\u{305}ae\u{306}ae\u{307}
ae\u{301}ae\u{301}ae\u{301}ae\u{301}ae\u{301}ae\u{301}ae\u{301}ae\u{300}
\u{f900}\u{f901}\u{f902}\u{f903}\u{f904}\u{f905}\u{f906}\u{f907}\u{f908}\u{f909}\u{f90a}
\u{f90b}\u{f90c}\u{f90d}\u{f90e}\u{f90f}\u{f910}\u{f911}\u{f912}\u{f913}\u{f914}\u{f915}\u{f916}\u{f917}\u{f918}\u{f919}
\u{f900}\u{f91a}\u{f91b}\u{f91c}\u{f91d}\u{f91e}\u{f91f}\u{f920}\u{f921}\u{f922}
""".lines(),
scaleMultiplier: 1/20
)
// static let pathological = """
// """.lines()
static let zalgo = Workload(
name: "Zalgo",
payload: """
ṭ̴̵̶̷̸̢̧̨̡̛̤̥̦̩̪̫̬̭̮̯̰̖̗̘̙̜̝̞̟̠̱̲̳̹̺̻̼͇͈͉͍͎̀́̂̃̄̅̆̇̈̉ͣͤ̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀́͂̓̈́͆͊͋͌̕̚͜͟͢͝͞͠͡ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮ͘͜͟͢͝͞͠͡
h̀́̂̃
è͇͈͉͍͎́̂̃̄̅̆̇̈̉͊͋͌͏̡̢̧̨̛͓͔͕͖͙͚̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭͇͈͉͍͎͐͑͒͗͛̊̋̌̍̎̏̐̑̒̓̔̀́͂̓̈́͆͊͋͌͘̕̚͜͟͝͞͠ͅ͏͓͔͕͖͐͑͒
q̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼͇̀́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀́͂̓̈́͆̕̚ͅ
ư̴̵̶̷̸̗̘̙̜̹̺̻̼͇͈͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮ͘͜͟͢͝͞͠͡
ì̡̢̧̨̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̹̺̻̼͇͈͉͍͎́̂̃̄̉̊̋̌̍̎̏̐̑̒̓̽̾̿̀́͂̓̈́͆͊͋͌ͅ͏͓͔͕͖͙͐͑͒͗ͬͭͮ͘
c̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼̀́̂̃̄̔̽̾̿̀́͂̓̈́͆ͣͤͥͦͧͨͩͪͫͬͭͮ̕̚͢͡ͅ
k̴̵̶̷̸̡̢̧̨̛̖̗̘̙̜̝̞̟̠̣̤̥̦̩̪̫̬̭̮̯̰̱̲̳̹̺̻̼͇͈͉͍͎̀́̂̃̄̅̆̇̈̉̊̋̌̍̎̏̐̑̒̓̔̽̾̿̀́͂̓̈́͆͊͋͌̕̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮ͘͜͟͢͝͞͠͡
b̴̵̶̷̸̡̢̛̗̘̙̜̝̞̟̠̹̺̻̼͇͈͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮ͘͜͟͢͝͞͠͡
ŗ̴̵̶̷̸̨̛̩̪̫̯̰̱̲̳̹̺̻̼̬̭̮͇̗̘̙̜̝̞̟̤̥̦͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏̡̢͓͔͕͖͙͚̠̣͐͑͒͗͛ͣͤͥͦͧͨͩͪͫͬͭͮ͘͜͟͢͝͞͠͡
o
w̗̘͇͈͉͍͎̓̈́͆͊͋͌ͅ͏̛͓͔͕͖͙͚̙̜̹̺̻̼͐͑͒͗͛ͣͤͥͦ̽̾̿̀́͂ͧͨͩͪͫͬͭͮ͘̚͜͟͢͝͞͠͡
n͇͈͉͍͎͊͋͌ͧͨͩͪͫͬͭͮ͏̛͓͔͕͖͙͚̗̘̙̜̹̺̻̼͐͑͒͗͛ͣͤͥͦ̽̾̿̀́͂̓̈́͆ͧͨͩͪͫͬͭͮ͘̚͜͟͢͝͞͠͡ͅ
f̛̗̘̙̜̹̺̻̼͇͈͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͣͤͥͦ͘͜͟͢͝͞͠͡
ơ̗̘̙̜̹̺̻̼͇͈͉͍͎̽̾̿̀́͂̓̈́͆͊͋͌̚ͅ͏͓͔͕͖͙͚͐͑͒͗͛ͥͦͧͨͩͪͫͬͭͮ͘
xͣͤͥͦͧͨͩͪͫͬͭͮ
""".lines(),
scaleMultiplier: 1/100
)
static let longSharedPrefix = Workload(
name: "LongSharedPrefix",
payload: """
http://www.dogbook.com/dog/239495828/friends/mutual/2939493815
http://www.dogbook.com/dog/239495828/friends/mutual/3910583739
http://www.dogbook.com/dog/239495828/friends/mutual/3910583739/shared
http://www.dogbook.com/dog/239495828/friends/mutual/3910583739/shared
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.🤔
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
🤔Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.🤔
""".lines()
)
}
// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End:
|