File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ set(SWIFT_BENCH_MODULES
37
37
single-source/CaptureProp
38
38
single-source/Chars
39
39
single-source/ClassArrayGetter
40
+ single-source/Data
40
41
single-source/DeadArray
41
42
single-source/DictionaryBridge
42
43
single-source/DictionaryLiteral
Original file line number Diff line number Diff line change
1
+ //===--- Data.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
+ import Foundation
15
+
16
+ @inline ( never)
17
+ func generateData( ) -> Data {
18
+ var data = Data ( count: 16 * 1024 )
19
+ data. withUnsafeMutableBytes { ( ptr: UnsafeMutablePointer < UInt8 > ) -> ( ) in
20
+ for i in 0 ..< data. count {
21
+ ptr [ i] = UInt8 ( i % 23 )
22
+ }
23
+ }
24
+ return data
25
+ }
26
+
27
+ @inline ( never)
28
+ public func run_IterateData( _ N: Int ) {
29
+ let data = generateData ( )
30
+
31
+ for _ in 0 ... 10 * N {
32
+ _ = data. reduce ( 0 , + )
33
+ }
34
+ }
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ import Calculator
38
38
import CaptureProp
39
39
import Chars
40
40
import ClassArrayGetter
41
+ import Data
41
42
import DeadArray
42
43
import DictTest
43
44
import DictTest2
@@ -141,6 +142,7 @@ precommitTests = [
141
142
" HashTest " : run_HashTest,
142
143
" Histogram " : run_Histogram,
143
144
" Integrate " : run_Integrate,
145
+ " IterateData " : run_IterateData,
144
146
" Join " : run_Join,
145
147
" LinkedList " : run_LinkedList,
146
148
" MapReduce " : run_MapReduce,
You can’t perform that action at this time.
0 commit comments