|
16 | 16 | // See the License for the specific language governing permissions and
|
17 | 17 | // limitations under the License.
|
18 | 18 |
|
| 19 | +import Foundation |
19 | 20 | import PackageDescription
|
20 | 21 |
|
21 | 22 | let librarySettings: [SwiftSetting] = []
|
@@ -227,71 +228,81 @@ let package = Package(
|
227 | 228 |
|
228 | 229 | // MARK: - Benchmarks
|
229 | 230 |
|
230 |
| -package.dependencies += [ |
231 |
| - .package(url: "https://github.com/ordo-one/package-benchmark", .upToNextMajor(from: "1.4.0")), |
232 |
| -] |
233 |
| -package.products += [.library(name: "_BenchmarkUtilities", targets: ["_BenchmarkUtilities"])] |
234 |
| -package.targets += [ |
235 |
| - .target( |
236 |
| - name: "_BenchmarkUtilities", |
237 |
| - dependencies: [ |
238 |
| - .product(name: "Benchmark", package: "package-benchmark"), |
239 |
| - "HomomorphicEncryption", |
240 |
| - "HomomorphicEncryptionProtobuf", |
241 |
| - "PrivateInformationRetrieval", |
242 |
| - "PrivateInformationRetrievalProtobuf", |
243 |
| - "PrivateNearestNeighborSearch", |
244 |
| - "PrivateNearestNeighborSearchProtobuf", |
245 |
| - ], |
246 |
| - path: "Sources/BenchmarkUtilities", |
247 |
| - swiftSettings: benchmarkSettings), |
248 |
| - .executableTarget( |
249 |
| - name: "PolyBenchmark", |
250 |
| - dependencies: [ |
251 |
| - .product(name: "Benchmark", package: "package-benchmark"), |
252 |
| - "HomomorphicEncryption", |
253 |
| - ], |
254 |
| - path: "Benchmarks/PolyBenchmark", |
255 |
| - swiftSettings: benchmarkSettings, |
256 |
| - plugins: [ |
257 |
| - .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), |
258 |
| - ]), |
259 |
| - .executableTarget( |
260 |
| - name: "RlweBenchmark", |
261 |
| - dependencies: [ |
262 |
| - .product(name: "Benchmark", package: "package-benchmark"), |
263 |
| - "HomomorphicEncryption", |
264 |
| - ], |
265 |
| - path: "Benchmarks/RlweBenchmark", |
266 |
| - swiftSettings: benchmarkSettings, |
267 |
| - plugins: [ |
268 |
| - .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), |
269 |
| - ]), |
270 |
| - .executableTarget( |
271 |
| - name: "PIRBenchmark", |
272 |
| - dependencies: [ |
273 |
| - .product(name: "Benchmark", package: "package-benchmark"), |
274 |
| - "HomomorphicEncryption", |
275 |
| - "_BenchmarkUtilities", |
276 |
| - ], |
277 |
| - path: "Benchmarks/PrivateInformationRetrievalBenchmark", |
278 |
| - swiftSettings: benchmarkSettings, |
279 |
| - plugins: [ |
280 |
| - .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), |
281 |
| - ]), |
282 |
| - .executableTarget( |
283 |
| - name: "PNNSBenchmark", |
284 |
| - dependencies: [ |
285 |
| - .product(name: "Benchmark", package: "package-benchmark"), |
286 |
| - "HomomorphicEncryption", |
287 |
| - "_BenchmarkUtilities", |
288 |
| - ], |
289 |
| - path: "Benchmarks/PrivateNearestNeighborSearchBenchmark", |
290 |
| - swiftSettings: benchmarkSettings, |
291 |
| - plugins: [ |
292 |
| - .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), |
293 |
| - ]), |
294 |
| -] |
| 231 | +var enableBenchmarking: Bool { |
| 232 | + let benchmarkFlags = "SWIFT_HOMOMORPHIC_ENCRYPTION_ENABLE_BENCHMARKING" |
| 233 | + if let flag = ProcessInfo.processInfo.environment[benchmarkFlags], flag == "1" { |
| 234 | + return true |
| 235 | + } |
| 236 | + return false |
| 237 | +} |
| 238 | + |
| 239 | +if enableBenchmarking { |
| 240 | + package.dependencies += [ |
| 241 | + .package(url: "https://github.com/ordo-one/package-benchmark", .upToNextMajor(from: "1.4.0")), |
| 242 | + ] |
| 243 | + package.products += [.library(name: "_BenchmarkUtilities", targets: ["_BenchmarkUtilities"])] |
| 244 | + package.targets += [ |
| 245 | + .target( |
| 246 | + name: "_BenchmarkUtilities", |
| 247 | + dependencies: [ |
| 248 | + .product(name: "Benchmark", package: "package-benchmark"), |
| 249 | + "HomomorphicEncryption", |
| 250 | + "HomomorphicEncryptionProtobuf", |
| 251 | + "PrivateInformationRetrieval", |
| 252 | + "PrivateInformationRetrievalProtobuf", |
| 253 | + "PrivateNearestNeighborSearch", |
| 254 | + "PrivateNearestNeighborSearchProtobuf", |
| 255 | + ], |
| 256 | + path: "Sources/BenchmarkUtilities", |
| 257 | + swiftSettings: benchmarkSettings), |
| 258 | + .executableTarget( |
| 259 | + name: "PolyBenchmark", |
| 260 | + dependencies: [ |
| 261 | + .product(name: "Benchmark", package: "package-benchmark"), |
| 262 | + "HomomorphicEncryption", |
| 263 | + ], |
| 264 | + path: "Benchmarks/PolyBenchmark", |
| 265 | + swiftSettings: benchmarkSettings, |
| 266 | + plugins: [ |
| 267 | + .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), |
| 268 | + ]), |
| 269 | + .executableTarget( |
| 270 | + name: "RlweBenchmark", |
| 271 | + dependencies: [ |
| 272 | + .product(name: "Benchmark", package: "package-benchmark"), |
| 273 | + "HomomorphicEncryption", |
| 274 | + ], |
| 275 | + path: "Benchmarks/RlweBenchmark", |
| 276 | + swiftSettings: benchmarkSettings, |
| 277 | + plugins: [ |
| 278 | + .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), |
| 279 | + ]), |
| 280 | + .executableTarget( |
| 281 | + name: "PIRBenchmark", |
| 282 | + dependencies: [ |
| 283 | + .product(name: "Benchmark", package: "package-benchmark"), |
| 284 | + "HomomorphicEncryption", |
| 285 | + "_BenchmarkUtilities", |
| 286 | + ], |
| 287 | + path: "Benchmarks/PrivateInformationRetrievalBenchmark", |
| 288 | + swiftSettings: benchmarkSettings, |
| 289 | + plugins: [ |
| 290 | + .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), |
| 291 | + ]), |
| 292 | + .executableTarget( |
| 293 | + name: "PNNSBenchmark", |
| 294 | + dependencies: [ |
| 295 | + .product(name: "Benchmark", package: "package-benchmark"), |
| 296 | + "HomomorphicEncryption", |
| 297 | + "_BenchmarkUtilities", |
| 298 | + ], |
| 299 | + path: "Benchmarks/PrivateNearestNeighborSearchBenchmark", |
| 300 | + swiftSettings: benchmarkSettings, |
| 301 | + plugins: [ |
| 302 | + .plugin(name: "BenchmarkPlugin", package: "package-benchmark"), |
| 303 | + ]), |
| 304 | + ] |
| 305 | +} |
295 | 306 |
|
296 | 307 | // Set the minimum macOS version for the package
|
297 | 308 | #if canImport(Darwin)
|
|
0 commit comments