File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ set(SWIFT_BENCH_MODULES
85
85
single-source/SuperChars
86
86
single-source/TwoSum
87
87
single-source/TypeFlood
88
+ single-source/UTF8Decode
88
89
single-source/Walsh
89
90
single-source/XorLoop
90
91
)
Original file line number Diff line number Diff line change
1
+ //===--- UTF8Decode.swift -------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See http://swift.org/LICENSE.txt for license information
9
+ // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ import TestsUtils
14
+
15
+ @inline ( never)
16
+ public func run_UTF8Decode( N: Int ) {
17
+ // Use test data with UTF-8 sequences of all lengths, but mainly ASCII.
18
+ let string = " Mainly ASCII but also some 2-byte sequences (пример), "
19
+ + " some 3-bytes sequences (성능 테스트) and occasionally a 🐼 (4 bytes) "
20
+ let data = Array ( string. utf8)
21
+ for _ in 1 ... N {
22
+ var generator = data. generate ( )
23
+ var utf8 = UTF8 ( )
24
+ while !utf8. decode ( & generator) . isEmptyInput ( ) { }
25
+ }
26
+ }
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ import StringWalk
90
90
import SuperChars
91
91
import TwoSum
92
92
import TypeFlood
93
+ import UTF8Decode
93
94
import Walsh
94
95
import XorLoop
95
96
@@ -171,6 +172,7 @@ precommitTests = [
171
172
" SuperChars " : run_SuperChars,
172
173
" TwoSum " : run_TwoSum,
173
174
" TypeFlood " : run_TypeFlood,
175
+ " UTF8Decode " : run_UTF8Decode,
174
176
" Walsh " : run_Walsh,
175
177
" XorLoop " : run_XorLoop,
176
178
]
You can’t perform that action at this time.
0 commit comments