File tree Expand file tree Collapse file tree 5 files changed +63
-0
lines changed Expand file tree Collapse file tree 5 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ set(SWIFT_BENCH_MODULES
192
192
single-source/WordCount
193
193
single-source/XorLoop
194
194
cxx-source/CreateObjects
195
+ cxx-source/GlobalVars
195
196
)
196
197
197
198
set (SWIFT_MULTISOURCE_SWIFT_BENCHES
Original file line number Diff line number Diff line change
1
+ //===--- GlobalVars.swift -------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift.org open source project
4
+ //
5
+ // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See https://swift.org/LICENSE.txt for license information
9
+ // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
+ //
11
+ //===----------------------------------------------------------------------===//
12
+
13
+ // This is a simple test that creates thousands of C++ objects and does nothing
14
+ // with them.
15
+
16
+ import TestsUtils
17
+ import CxxGlobalVars
18
+
19
+ public let GlobalVars = BenchmarkInfo (
20
+ name: " GlobalVars " ,
21
+ runFunction: run_GlobalVars,
22
+ tags: [ . validation, . bridging] )
23
+
24
+ @inline ( never)
25
+ public func run_GlobalVars( _ N: Int ) {
26
+ for i in 0 ... ( N * 10_000 ) {
27
+ let localVar1 = globalInt
28
+ let localVar2 = globalConstexprInt
29
+ let localVar3 = globalFloat
30
+ let localVar4 = globalConstexprFloat
31
+ let localVar5 = globalBigObject
32
+ let localVar6 = globalConstexprBigObject
33
+ blackHole ( localVar1)
34
+ blackHole ( localVar2)
35
+ blackHole ( localVar3)
36
+ blackHole ( localVar4)
37
+ blackHole ( localVar5)
38
+ blackHole ( localVar6)
39
+ }
40
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef BENCHMARK_GLOBAL_VARS_H
2
+ #define BENCHMARK_GLOBAL_VARS_H
3
+
4
+ static int globalInt = 42 ;
5
+ static constexpr int globalConstexprInt = 42 ;
6
+ static float globalFloat = 42 ;
7
+ static constexpr float globalConstexprFloat = 42 ;
8
+
9
+ struct BigObject {
10
+ char buff [512 ];
11
+ };
12
+ static BigObject globalBigObject = BigObject ();
13
+ static constexpr BigObject globalConstexprBigObject = BigObject ();
14
+
15
+ #endif // BENCHMARK_GLOBAL_VARS_H
Original file line number Diff line number Diff line change 1
1
module CxxCreateObjects {
2
2
header "CreateObjects.h"
3
3
}
4
+
5
+ module CxxGlobalVars {
6
+ header "GlobalVars.h"
7
+ requires cplusplus
8
+ }
Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ import FlattenList
86
86
import FloatingPointConversion
87
87
import FloatingPointParsing
88
88
import FloatingPointPrinting
89
+ import GlobalVars
89
90
import Hanoi
90
91
import Hash
91
92
import Histogram
@@ -280,6 +281,7 @@ registerBenchmark(FlattenListFlatMap)
280
281
registerBenchmark ( FloatingPointConversion)
281
282
registerBenchmark ( FloatingPointParsing)
282
283
registerBenchmark ( FloatingPointPrinting)
284
+ registerBenchmark ( GlobalVars)
283
285
registerBenchmark ( Hanoi)
284
286
registerBenchmark ( HashTest)
285
287
registerBenchmark ( Histogram)
You can’t perform that action at this time.
0 commit comments