Apply review feedback

This commit is contained in:
David Nadoba committed 2023-08-22 08:55:21 +01:00
1 parent 6b7c04f2ad
commit e6905bfcef
7 files changed
+11 -32

No files matched your search

@@ -16,7 +16,12 @@ import Benchmark
import Sources
let benchmarks = {
Benchmark("Verifier", configuration: .init(warmupIterations: 1)) { benchmark in
Benchmark.defaultConfiguration = .init(
metrics: [.mallocCountTotal],
warmupIterations: 1
)
Benchmark("Verifier") { benchmark in
await verifier()
}
+1
View File
@@ -28,6 +28,7 @@ let package = Package(
.target(
name: "Sources",
dependencies: [
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "X509", package: "swift-certificates"),
.product(name: "SwiftASN1", package: "swift-asn1"),
.product(name: "Crypto", package: "swift-crypto"),
+1
View File
@@ -15,6 +15,7 @@
import X509
import SwiftASN1
import Foundation
import Benchmark
public func parseWebPKIRoots() -> () -> Void {
let derEncodedCAs = WebPKI.all.map { try! PEMDocument(pemString: $0).derBytes }
+1
View File
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
import _CertificateInternals
import Benchmark
public func tinyArrayAppend() {
var count = 0
@@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
import _CertificateInternals
import Benchmark
public func tinyArrayNonAllocationFunctions() {
var counts = 0
@@ -16,6 +16,7 @@ import X509
import Foundation
import Crypto
import SwiftASN1
import Benchmark
public func verifier() async {
var counts = 0
-31
View File
@@ -1,31 +0,0 @@
// ===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2021 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
// ===----------------------------------------------------------------------===//
/// A function to foil compiler optimizations that would otherwise optimize out code you want to benchmark.
///
/// The function wraps another object or function, does nothing, and returns.
/// If you want to benchmark the time is takes to create an instance and you don't maintain a reference to it, the compiler may optimize it out entirely, thinking it is unused.
/// To prevent the compiler from removing the code you want to measure, wrap the creation of the instance with `blackHole`.
/// For example, the following code benchmarks the time it takes to create an instance of `Date`, and wraps the creation of the instance to prevent the compiler from optimizing it away:
///
/// ```swift
/// Benchmark("Foundation Date()",
/// configuration: .init(
/// metrics: [.throughput, .wallClock],
/// scalingFactor: .mega)
/// ) { benchmark in
/// for _ in benchmark.scaledIterations {
/// blackHole(Date())
/// }
/// }
/// ```
@inline(never)
public func blackHole(_: some Any) {}