Skip to content

Commit 2c62011

Browse files
committed
[benchmark] Don't hard code directory structure
1 parent 32872cb commit 2c62011

File tree

4 files changed

+106
-97
lines changed

4 files changed

+106
-97
lines changed

benchmark/CMakeLists.txt

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -15,84 +15,84 @@ list(APPEND CMAKE_MODULE_PATH
1515
include(AddSwiftBenchmarkSuite)
1616

1717
set(SWIFT_BENCH_MODULES
18-
Ackermann
19-
AngryPhonebook
20-
Array2D
21-
ArrayAppend
22-
ArrayInClass
23-
ArrayLiteral
24-
ArrayOfGenericPOD
25-
ArrayOfGenericRef
26-
ArrayOfPOD
27-
ArrayOfRef
28-
ArraySubscript
29-
BitCount
30-
ByteSwap
31-
Calculator
32-
CaptureProp
33-
Chars
34-
ClassArrayGetter
35-
DeadArray
36-
DictionaryBridge
37-
DictionaryLiteral
38-
DictionaryRemove
39-
DictionarySwap
40-
DictTest
41-
DictTest2
42-
DictTest3
43-
ErrorHandling
44-
Fibonacci
45-
GlobalClass
46-
Hanoi
47-
Hash
48-
Histogram
49-
Join
50-
LinkedList
51-
MapReduce
52-
Memset
53-
MonteCarloE
54-
MonteCarloPi
55-
NopDeinit
56-
NSDictionaryCastToSwift
57-
NSError
58-
NSStringConversion
59-
ObjectAllocation
60-
OpenClose
61-
Phonebook
62-
PolymorphicCalls
63-
PopFront
64-
PopFrontGeneric
65-
Prims
66-
ProtocolDispatch
67-
RangeAssignment
68-
RC4
69-
RecursiveOwnedParameter
70-
RGBHistogram
71-
SetTests
72-
SevenBoom
73-
Sim2DArray
74-
SortLettersInPlace
75-
SortStrings
76-
StrComplexWalk
77-
StringBuilder
78-
StringInterpolation
79-
StringTests
80-
StringWalk
81-
StrToInt
82-
SuperChars
83-
TypeFlood
84-
TwoSum
85-
Walsh
86-
XorLoop
18+
single-source/Ackermann
19+
single-source/AngryPhonebook
20+
single-source/Array2D
21+
single-source/ArrayAppend
22+
single-source/ArrayInClass
23+
single-source/ArrayLiteral
24+
single-source/ArrayOfGenericPOD
25+
single-source/ArrayOfGenericRef
26+
single-source/ArrayOfPOD
27+
single-source/ArrayOfRef
28+
single-source/ArraySubscript
29+
single-source/BitCount
30+
single-source/ByteSwap
31+
single-source/Calculator
32+
single-source/CaptureProp
33+
single-source/Chars
34+
single-source/ClassArrayGetter
35+
single-source/DeadArray
36+
single-source/DictionaryBridge
37+
single-source/DictionaryLiteral
38+
single-source/DictionaryRemove
39+
single-source/DictionarySwap
40+
single-source/DictTest
41+
single-source/DictTest2
42+
single-source/DictTest3
43+
single-source/ErrorHandling
44+
single-source/Fibonacci
45+
single-source/GlobalClass
46+
single-source/Hanoi
47+
single-source/Hash
48+
single-source/Histogram
49+
single-source/Join
50+
single-source/LinkedList
51+
single-source/MapReduce
52+
single-source/Memset
53+
single-source/MonteCarloE
54+
single-source/MonteCarloPi
55+
single-source/NopDeinit
56+
single-source/NSDictionaryCastToSwift
57+
single-source/NSError
58+
single-source/NSStringConversion
59+
single-source/ObjectAllocation
60+
single-source/OpenClose
61+
single-source/Phonebook
62+
single-source/PolymorphicCalls
63+
single-source/PopFront
64+
single-source/PopFrontGeneric
65+
single-source/Prims
66+
single-source/ProtocolDispatch
67+
single-source/RangeAssignment
68+
single-source/RC4
69+
single-source/RecursiveOwnedParameter
70+
single-source/RGBHistogram
71+
single-source/SetTests
72+
single-source/SevenBoom
73+
single-source/Sim2DArray
74+
single-source/SortLettersInPlace
75+
single-source/SortStrings
76+
single-source/StrComplexWalk
77+
single-source/StringBuilder
78+
single-source/StringInterpolation
79+
single-source/StringTests
80+
single-source/StringWalk
81+
single-source/StrToInt
82+
single-source/SuperChars
83+
single-source/TwoSum
84+
single-source/TypeFlood
85+
single-source/Walsh
86+
single-source/XorLoop
8787
)
8888

8989
set(SWIFT_MULTISOURCE_BENCHES
9090
)
9191

9292

9393
set(BENCH_DRIVER_LIBRARY_MODULES
94-
DriverUtils
95-
TestsUtils
94+
utils/DriverUtils
95+
utils/TestsUtils
9696
)
9797

9898
set(BENCH_DRIVER_LIBRARY_FLAGS)

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ function (swift_benchmark_compile_archopts)
6868

6969
set(bench_library_objects)
7070
set(bench_library_sibfiles)
71-
foreach(module_name ${BENCH_DRIVER_LIBRARY_MODULES})
71+
foreach(module_name_path ${BENCH_DRIVER_LIBRARY_MODULES})
72+
get_filename_component(module_name "${module_name_path}" NAME)
73+
7274
if("${module_name}" STREQUAL "DriverUtils")
7375
set(extra_sources "${srcdir}/utils/ArgParse.swift")
7476
endif()
7577

7678
set(objfile "${objdir}/${module_name}.o")
7779
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
7880
list(APPEND bench_library_objects "${objfile}")
79-
set(source "${srcdir}/utils/${module_name}.swift")
81+
set(source "${srcdir}/${module_name_path}.swift")
8082
add_custom_command(
8183
OUTPUT "${objfile}"
8284
DEPENDS ${stdlib_dependencies} "${source}" ${extra_sources}
@@ -95,7 +97,7 @@ function (swift_benchmark_compile_archopts)
9597
add_custom_command(
9698
OUTPUT "${sibfile}"
9799
DEPENDS
98-
${stdlib_dependencies} "${srcdir}/utils/${module_name}.swift"
100+
${stdlib_dependencies} "${srcdir}/${module_name_path}.swift"
99101
${extra_sources}
100102
COMMAND "${SWIFT_EXEC}"
101103
${common_options_driver}
@@ -105,18 +107,20 @@ function (swift_benchmark_compile_archopts)
105107
"-module-name" "${module_name}"
106108
"-emit-sib"
107109
"-o" "${sibfile}"
108-
"${srcdir}/utils/${module_name}.swift" ${extra_sources})
110+
"${srcdir}/${module_name_path}.swift" ${extra_sources})
109111
endif()
110112
endforeach()
111113

112-
foreach(module_name ${BENCH_LIBRARY_MODULES})
114+
foreach(module_name_path ${BENCH_LIBRARY_MODULES})
115+
get_filename_component(module_name "${module_name_path}" NAME)
116+
113117
set(objfile "${objdir}/${module_name}.o")
114118
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
115119
list(APPEND bench_library_objects "${objfile}")
116120
add_custom_command(
117121
OUTPUT "${objfile}"
118122
DEPENDS
119-
${stdlib_dependencies} "${srcdir}/utils/${module_name}.swift"
123+
${stdlib_dependencies} "${srcdir}/${module_name_path}.swift"
120124
${extra_sources}
121125
COMMAND "${SWIFT_EXEC}"
122126
${common_options}
@@ -125,14 +129,14 @@ function (swift_benchmark_compile_archopts)
125129
"-module-name" "${module_name}"
126130
"-emit-module" "-emit-module-path" "${swiftmodule}"
127131
"-o" "${objfile}"
128-
"${srcdir}/utils/${module_name}.swift" ${extra_sources})
132+
"${srcdir}/${module_name_path}.swift" ${extra_sources})
129133
if (SWIFT_BENCHMARK_EMIT_SIB)
130134
set(sibfile "${objdir}/${module_name}.sib")
131135
list(APPEND bench_library_sibfiles "${sibfile}")
132136
add_custom_command(
133137
OUTPUT "${sibfile}"
134138
DEPENDS
135-
${stdlib_dependencies} "${srcdir}/utils/${module_name}.swift"
139+
${stdlib_dependencies} "${srcdir}/${module_name_path}.swift"
136140
${extra_sources}
137141
COMMAND "${SWIFT_EXEC}"
138142
${common_options}
@@ -141,13 +145,15 @@ function (swift_benchmark_compile_archopts)
141145
"-module-name" "${module_name}"
142146
"-emit-sib"
143147
"-o" "${sibfile}"
144-
"${srcdir}/utils/${module_name}.swift" ${extra_sources})
148+
"${srcdir}/${module_name_path}.swift" ${extra_sources})
145149
endif()
146150
endforeach()
147151

148152
set(SWIFT_BENCH_OBJFILES)
149153
set(SWIFT_BENCH_SIBFILES)
150-
foreach(module_name ${SWIFT_BENCH_MODULES})
154+
foreach(module_name_path ${SWIFT_BENCH_MODULES})
155+
get_filename_component(module_name "${module_name_path}" NAME)
156+
151157
if(module_name)
152158
set(objfile "${objdir}/${module_name}.o")
153159
set(swiftmodule "${objdir}/${module_name}.swiftmodule")
@@ -156,7 +162,7 @@ function (swift_benchmark_compile_archopts)
156162
OUTPUT "${objfile}"
157163
DEPENDS
158164
${stdlib_dependencies} ${bench_library_objects}
159-
"${srcdir}/single-source/${module_name}.swift"
165+
"${srcdir}/${module_name_path}.swift"
160166
COMMAND "${SWIFT_EXEC}"
161167
${common_options}
162168
"-parse-as-library"
@@ -165,15 +171,15 @@ function (swift_benchmark_compile_archopts)
165171
"-emit-module" "-emit-module-path" "${swiftmodule}"
166172
"-I" "${objdir}"
167173
"-o" "${objfile}"
168-
"${srcdir}/single-source/${module_name}.swift")
174+
"${srcdir}/${module_name_path}.swift")
169175
if (SWIFT_BENCHMARK_EMIT_SIB)
170176
set(sibfile "${objdir}/${module_name}.sib")
171177
list(APPEND SWIFT_BENCH_SIBFILES "${sibfile}")
172178
add_custom_command(
173179
OUTPUT "${sibfile}"
174180
DEPENDS
175181
${stdlib_dependencies} ${bench_library_sibfiles}
176-
"${srcdir}/single-source/${module_name}.swift"
182+
"${srcdir}/${module_name_path}.swift"
177183
COMMAND "${SWIFT_EXEC}"
178184
${common_options}
179185
"-parse-as-library"
@@ -182,12 +188,14 @@ function (swift_benchmark_compile_archopts)
182188
"-I" "${objdir}"
183189
"-emit-sib"
184190
"-o" "${sibfile}"
185-
"${srcdir}/single-source/${module_name}.swift")
191+
"${srcdir}/${module_name_path}.swift")
186192
endif()
187193
endif()
188194
endforeach()
189195

190-
foreach(module_name ${SWIFT_MULTISOURCE_BENCHES})
196+
foreach(module_name_path ${SWIFT_MULTISOURCE_BENCHES})
197+
get_filename_component(module_name "${module_name_path}" NAME)
198+
191199
if ("${bench_flags}" MATCHES "-whole-module.*" AND
192200
NOT "${bench_flags}" MATCHES "-num-threads.*")
193201
# Regular whole-module-compilation: only a single object file is
@@ -196,7 +204,7 @@ function (swift_benchmark_compile_archopts)
196204
list(APPEND SWIFT_BENCH_OBJFILES "${objfile}")
197205
set(sources)
198206
foreach(source ${${module_name}_sources})
199-
list(APPEND sources "${srcdir}/multi-source/${source}")
207+
list(APPEND sources "${srcdir}/${source}")
200208
endforeach()
201209
add_custom_command(
202210
OUTPUT "${objfile}"
@@ -219,13 +227,13 @@ function (swift_benchmark_compile_archopts)
219227
set(objfiles)
220228
set(json "{\n")
221229
foreach(source ${${module_name}_sources})
222-
list(APPEND sources "${srcdir}/multi-source/${source}")
230+
list(APPEND sources "${srcdir}/${source}")
223231

224232
get_filename_component(basename "${source}" NAME_WE)
225233
set(objfile "${objdir}/${module_name}/${basename}.o")
226234

227235
string(CONCAT json "${json}"
228-
" \"${srcdir}/multi-source/${source}\": { \"object\": \"${objfile}\" },\n")
236+
" \"${srcdir}/${source}\": { \"object\": \"${objfile}\" },\n")
229237

230238
list(APPEND objfiles "${objfile}")
231239
list(APPEND SWIFT_BENCH_OBJFILES "${objfile}")

benchmark/scripts/generate_harness/CMakeLists.txt_template

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ cmake_minimum_required(VERSION 2.8.12)
1212
list(APPEND CMAKE_MODULE_PATH
1313
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
1414

15-
include(add-swift-benchmark-suite)
15+
include(AddSwiftBenchmarkSuite)
1616

1717
set(SWIFT_BENCH_MODULES
1818
{% for test in tests %}
19-
{{ test }}
19+
single-source/{{ test }}
2020
{% endfor %}
2121
)
2222

2323
set(SWIFT_MULTISOURCE_BENCHES
2424
{% for multisource_bench in multisource_benches %}
25-
{{ multisource_bench.name }}
25+
multi-source/{{ multisource_bench.name }}
2626
{% endfor %}
2727
)
2828

2929
{% for multisource_bench in multisource_benches %}
3030
set({{ multisource_bench.name }}_sources
3131
{% for file in multisource_bench.files %}
32-
{{ multisource_bench.name }}/{{ file }}
32+
multi-source/{{ multisource_bench.name }}/{{ file }}
3333
{% endfor %}
3434
)
3535

3636
{% endfor %}
3737

3838
set(BENCH_DRIVER_LIBRARY_MODULES
39-
DriverUtils
40-
TestsUtils
39+
utils/DriverUtils
40+
utils/TestsUtils
4141
)
4242

4343
set(BENCH_DRIVER_LIBRARY_FLAGS)
@@ -155,3 +155,4 @@ foreach(platform ${platforms})
155155
endforeach()
156156

157157
add_subdirectory(scripts)
158+

benchmark/utils/main.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ import StringInterpolation
8585
import StringTests
8686
import StringWalk
8787
import SuperChars
88-
import TypeFlood
8988
import TwoSum
89+
import TypeFlood
9090
import Walsh
9191
import XorLoop
9292

@@ -163,8 +163,8 @@ precommitTests = [
163163
"StringWalk": run_StringWalk,
164164
"StringWithCString": run_StringWithCString,
165165
"SuperChars": run_SuperChars,
166-
"TypeFlood": run_TypeFlood,
167166
"TwoSum": run_TwoSum,
167+
"TypeFlood": run_TypeFlood,
168168
"Walsh": run_Walsh,
169169
"XorLoop": run_XorLoop,
170170
]

0 commit comments

Comments
 (0)