mirror of
https://github.com/apple/swift-certificates
synced 2026-11-27 04:54:20 +00:00
Apply review feedback
This commit is contained in:
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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {}
|
||||
Reference in new issue
Block a user