Apply swift-format changes and CI (#472)

Motivation:

Standardised formatting makes the project cleaner to look at and work
on.

Modifications:

Setup swift-format with the same settings as Swift-NIO

Result:

Common formatting throughout
This commit is contained in:
Peter Adams authored and GitHub committed 2024-10-29 13:09:54 +00:00
1 parent 93586110f2
commit 1118370ec4
125 files changed
+21869 -11457

No files matched your search

@@ -13,9 +13,9 @@
//===----------------------------------------------------------------------===//
import NIOCore
import NIOPosix
import NIOHTTP1
import NIOHTTP2
import NIOPosix
final class Bench1Conn10kRequests: Benchmark {
var group: MultiThreadedEventLoopGroup!
@@ -40,7 +40,7 @@ final class Bench1Conn10kRequests: Benchmark {
func run() throws -> Int {
var bodyByteCount = 0
for _ in 0 ..< 10_000 {
for _ in 0..<10_000 {
bodyByteCount += try sendOneRequest(channel: self.client, multiplexer: self.clientMultiplexer)
}
return bodyByteCount
@@ -55,14 +55,15 @@ func setupServer(group: EventLoopGroup) throws -> Channel {
// Set the handlers that are applied to the accepted Channels
.childChannelInitializer { channel in
return channel.configureHTTP2Pipeline(mode: .server) { streamChannel -> EventLoopFuture<Void> in
return streamChannel.pipeline.addHandler(HTTP2FramePayloadToHTTP1ServerCodec()).flatMap { () -> EventLoopFuture<Void> in
channel.configureHTTP2Pipeline(mode: .server) { streamChannel -> EventLoopFuture<Void> in
streamChannel.pipeline.addHandler(HTTP2FramePayloadToHTTP1ServerCodec()).flatMap {
() -> EventLoopFuture<Void> in
streamChannel.pipeline.addHandler(HTTP1TestServer())
}.flatMap { () -> EventLoopFuture<Void> in
streamChannel.pipeline.addHandler(ErrorHandler())
}
}.flatMap { (_: HTTP2StreamMultiplexer) in
return channel.pipeline.addHandler(ErrorHandler())
channel.pipeline.addHandler(ErrorHandler())
}
}
@@ -77,30 +78,39 @@ func setupServer(group: EventLoopGroup) throws -> Channel {
func sendOneRequest(channel: Channel, multiplexer: HTTP2StreamMultiplexer) throws -> Int {
let responseReceivedPromise = channel.eventLoop.makePromise(of: Int.self)
let requestStreamInitializer: NIOChannelInitializer = { channel in
return channel.pipeline.addHandlers([HTTP2FramePayloadToHTTP1ClientCodec(httpProtocol: .https),
SendRequestHandler(host: "127.0.0.1",
request: .init(version: .init(major: 2, minor: 0),
method: .GET,
uri: "/", headers: ["host": "localhost"]),
responseReceivedPromise: responseReceivedPromise),
ErrorHandler()],
position: .last)
channel.pipeline.addHandlers(
[
HTTP2FramePayloadToHTTP1ClientCodec(httpProtocol: .https),
SendRequestHandler(
host: "127.0.0.1",
request: .init(
version: .init(major: 2, minor: 0),
method: .GET,
uri: "/",
headers: ["host": "localhost"]
),
responseReceivedPromise: responseReceivedPromise
),
ErrorHandler(),
],
position: .last
)
}
channel.pipeline.handler(type: HTTP2StreamMultiplexer.self).whenSuccess { multiplexer in
multiplexer.createStreamChannel(promise: nil, requestStreamInitializer)
multiplexer.createStreamChannel(promise: nil, requestStreamInitializer)
}
return try responseReceivedPromise.futureResult.wait()
}
func setupClient(group: EventLoopGroup, address: SocketAddress) throws -> (Channel, HTTP2StreamMultiplexer) {
return try ClientBootstrap(group: group)
try ClientBootstrap(group: group)
.channelOption(ChannelOptions.socket(IPPROTO_TCP, TCP_NODELAY), value: 1)
.channelInitializer { channel in
channel.pipeline.addHandler(ErrorHandler())
}
.connect(to: address).flatMap { channel in
channel.configureHTTP2Pipeline(mode: .client, position: .first) { channel -> EventLoopFuture<Void> in
return channel.eventLoop.makeSucceededFuture(())
channel.eventLoop.makeSucceededFuture(())
}.map { (channel, $0) }
}.wait()
}
@@ -125,11 +135,21 @@ final class HTTP1TestServer: ChannelInboundHandler {
var headers = HTTPHeaders()
headers.add(name: "content-length", value: "5")
headers.add(name: "x-stream-id", value: String(Int(streamID)))
channel.write(loopBoundSelf.value.wrapOutboundOut(HTTPServerResponsePart.head(HTTPResponseHead(version: .init(major: 2, minor: 0), status: .ok, headers: headers))), promise: nil)
channel.write(
loopBoundSelf.value.wrapOutboundOut(
HTTPServerResponsePart.head(
HTTPResponseHead(version: .init(major: 2, minor: 0), status: .ok, headers: headers)
)
),
promise: nil
)
var buffer = channel.allocator.buffer(capacity: 12)
buffer.writeStaticString("hello")
channel.write(loopBoundSelf.value.wrapOutboundOut(HTTPServerResponsePart.body(.byteBuffer(buffer))), promise: nil)
channel.write(
loopBoundSelf.value.wrapOutboundOut(HTTPServerResponsePart.body(.byteBuffer(buffer))),
promise: nil
)
return channel.writeAndFlush(loopBoundSelf.value.wrapOutboundOut(HTTPServerResponsePart.end(nil)))
}.whenComplete { _ in
loopBoundContext.value.close(promise: nil)
@@ -39,10 +39,9 @@ final class HPACKHeaderCanonicalFormBenchmark {
}
}
extension HPACKHeaderCanonicalFormBenchmark: Benchmark {
func setUp() throws { }
func tearDown() { }
func setUp() throws {}
func tearDown() {}
func run() throws -> Int {
var count = 0
@@ -15,7 +15,6 @@
import NIOCore
import NIOHPACK
final class HPACKHeaderDecodingBenchmark {
private var headers: ByteBuffer
private let loopCount: Int
@@ -28,11 +27,10 @@ final class HPACKHeaderDecodingBenchmark {
}
}
extension HPACKHeaderDecodingBenchmark: Benchmark {
func setUp() throws { }
func setUp() throws {}
func tearDown() { }
func tearDown() {}
func run() throws -> Int {
for _ in 0..<self.loopCount {
@@ -44,7 +42,6 @@ extension HPACKHeaderDecodingBenchmark: Benchmark {
}
}
extension HPACKHeaders {
fileprivate var encoded: ByteBuffer {
var encoder = HPACKEncoder(allocator: .init())
@@ -15,7 +15,6 @@
import NIOCore
import NIOHPACK
final class HPACKHeaderEncodingBenchmark {
private let headers: HPACKHeaders
private let loopCount: Int
@@ -30,11 +29,10 @@ final class HPACKHeaderEncodingBenchmark {
}
}
extension HPACKHeaderEncodingBenchmark: Benchmark {
func setUp() throws { }
func setUp() throws {}
func tearDown() { }
func tearDown() {}
func run() throws -> Int {
for _ in 0..<self.loopCount {
@@ -46,26 +44,37 @@ extension HPACKHeaderEncodingBenchmark: Benchmark {
}
}
extension HPACKHeaders {
static let indexable: HPACKHeaders = {
var headers = HPACKHeaders()
headers.add(contentsOf: [(":method", "GET"), (":path", "/"), (":scheme", "https"), (":authority", "localhost"), ("foo", "bar")],
indexing: .indexable)
headers.add(
contentsOf: [
(":method", "GET"), (":path", "/"), (":scheme", "https"), (":authority", "localhost"), ("foo", "bar"),
],
indexing: .indexable
)
return headers
}()
static let nonIndexable: HPACKHeaders = {
var headers = HPACKHeaders()
headers.add(contentsOf: [(":method", "GET"), (":path", "/"), (":scheme", "https"), (":authority", "localhost"), ("foo", "bar")],
indexing: .nonIndexable)
headers.add(
contentsOf: [
(":method", "GET"), (":path", "/"), (":scheme", "https"), (":authority", "localhost"), ("foo", "bar"),
],
indexing: .nonIndexable
)
return headers
}()
static let neverIndexed: HPACKHeaders = {
var headers = HPACKHeaders()
headers.add(contentsOf: [(":method", "GET"), (":path", "/"), (":scheme", "https"), (":authority", "localhost"), ("foo", "bar")],
indexing: .neverIndexed)
headers.add(
contentsOf: [
(":method", "GET"), (":path", "/"), (":scheme", "https"), (":authority", "localhost"), ("foo", "bar"),
],
indexing: .neverIndexed
)
return headers
}()
}
@@ -31,7 +31,6 @@ final class HPACKHeadersNormalizationOfHTTPHeadersBenchmark {
}
}
extension HPACKHeadersNormalizationOfHTTPHeadersBenchmark: Benchmark {
func setUp() throws {
switch self.httpHeadersKind {
@@ -42,12 +41,12 @@ extension HPACKHeadersNormalizationOfHTTPHeadersBenchmark: Benchmark {
}
}
func tearDown() { }
func tearDown() {}
func run() throws -> Int {
var count = 0
for _ in 0 ..< self.iterations {
for _ in 0..<self.iterations {
let normalize = HPACKHeaders(httpHeaders: self.httpHeaders, normalizeHTTPHeaders: true)
count &+= normalize.count
}
@@ -61,10 +60,10 @@ extension HTTPHeaders {
var httpHeaders: HTTPHeaders = [:]
httpHeaders.reserveCapacity(count + 1)
let connectionHeaderValue = (0 ..< count).map(String.init).joined(separator: ",")
let connectionHeaderValue = (0..<count).map(String.init).joined(separator: ",")
httpHeaders.add(name: "connection", value: connectionHeaderValue)
for i in 0 ..< count {
for i in 0..<count {
let header = String(describing: i)
httpHeaders.add(name: header, value: header)
}
@@ -78,10 +77,10 @@ extension HTTPHeaders {
// Assuming connection header values are decomposed into an array then this is the
// worst case: the whole array must be scanned for each of the `count` headers we add below.
let connectionHeaderValue = (0 ..< count).map { _ in "a" }.joined(separator: ",")
let connectionHeaderValue = (0..<count).map { _ in "a" }.joined(separator: ",")
httpHeaders.add(name: "connection", value: connectionHeaderValue)
for _ in 0 ..< count {
for _ in 0..<count {
httpHeaders.add(name: "b", value: "")
}
@@ -16,7 +16,6 @@ import Foundation
import NIOCore
import NIOHPACK
/// This benchmark is mostly attempting to stress the Huffman Decoding implementation by
/// way of using larger or more complex strings.
final class HuffmanDecodingBenchmark {
@@ -27,7 +26,11 @@ final class HuffmanDecodingBenchmark {
init(huffmanBytes: TestType, loopCount: Int) {
self.loopCount = loopCount
self.decoder = HPACKDecoder(allocator: .init(), maxDynamicTableSize: HPACKDecoder.maxDynamicTableSize, maxHeaderListSize: .max)
self.decoder = HPACKDecoder(
allocator: .init(),
maxDynamicTableSize: HPACKDecoder.maxDynamicTableSize,
maxHeaderListSize: .max
)
self.buffer = ByteBufferAllocator().buffer(capacity: 1024)
self.testType = huffmanBytes
}
@@ -47,21 +50,21 @@ final class HuffmanDecodingBenchmark {
}
}
extension HuffmanDecodingBenchmark: Benchmark {
func setUp() throws {
// We encode this header with both the name and value as a huffman string, never indexed.
self.buffer.writeInteger(UInt8(0x10)) // Never indexed, non-indexed name
self.buffer.encodeInteger(1, prefix: 7, prefixBits: 0x80) // Name length, huffman encoded, 7-bit integer
self.buffer.writeInteger(UInt8(0x97)) // Huffman encoded "f"
self.buffer.encodeInteger(UInt(self.testType.huffmanBytes.count), prefix: 7, prefixBits: 0x80) // Value length, huffman encoded, 7-bit integer
// Value length, huffman encoded, 7-bit integer
self.buffer.encodeInteger(UInt(self.testType.huffmanBytes.count), prefix: 7, prefixBits: 0x80)
self.buffer.writeBytes(self.testType.huffmanBytes)
// Run a single iteration of the loop. This warms up the encoder and decoder and ensures all the pages are mapped.
try self.loopIteration()
}
func tearDown() { }
func tearDown() {}
func run() throws -> Int {
for _ in 0..<self.loopCount {
@@ -77,7 +80,6 @@ extension HuffmanDecodingBenchmark: Benchmark {
}
}
extension Array where Element == UInt8 {
static let basicHuffmanBytes: [UInt8] = {
// This is hilariously slow (TWO intermediate Data objects!) but it's only invoked in setup so who cares?
@@ -95,10 +97,12 @@ extension Array where Element == UInt8 {
}()
// The location of the test fixtures.
private static let fixtureDirectoryURL = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().appendingPathComponent("Tests").appendingPathComponent("NIOHPACKTests").appendingPathComponent("Fixtures").absoluteURL
private static let fixtureDirectoryURL = URL(fileURLWithPath: #filePath).deletingLastPathComponent()
.deletingLastPathComponent().deletingLastPathComponent().appendingPathComponent("Tests").appendingPathComponent(
"NIOHPACKTests"
).appendingPathComponent("Fixtures").absoluteURL
}
extension ByteBuffer {
// Copied directly from our internal implementation.
fileprivate mutating func encodeInteger(_ value: UInt, prefix: Int, prefixBits: UInt8 = 0) {
@@ -15,7 +15,6 @@
import NIOCore
import NIOHPACK
/// This benchmark is mostly attempting to stress the Huffman Encoding implementation by
/// way of using larger or more complex strings.
final class HuffmanEncodingBenchmark {
@@ -34,14 +33,13 @@ final class HuffmanEncodingBenchmark {
}
}
extension HuffmanEncodingBenchmark: Benchmark {
func setUp() throws {
// Run a single iteration of the loop. This warms up the encoder and decoder and ensures all the pages are mapped.
try self.loopIteration()
}
func tearDown() { }
func tearDown() {}
func run() throws -> Int {
for _ in 0..<self.loopCount {
@@ -57,17 +55,17 @@ extension HuffmanEncodingBenchmark: Benchmark {
}
}
extension String {
static let basicHuffmanString: String = {
var text = "Hello, world. I am a header value; I have Teh Texts. I am going on for quite a long time because I want to ensure that the encoded data buffer needs to be expanded to test out that code. I'll try some meta-characters too: \r\t\n ought to do it, no?"
static let basicHuffman: String = {
var text =
"Hello, world. I am a header value; I have Teh Texts. I am going on for quite a long time because I want to ensure that the encoded data buffer needs to be expanded to test out that code. I'll try some meta-characters too: \r\t\n ought to do it, no?"
while text.count < 1024 * 128 {
text += text
}
return text
}()
static let complexHuffmanString: String = {
static let complexHuffman: String = {
var text = "午セイ谷高ぐふあト食71入ツエヘナ津県を類及オモ曜一購ごきわ致掲ぎぐず敗文輪へけり鯖審ヘ塊米卸呪おぴ。"
while text.utf8.count < 128 * 1024 {
text += text
@@ -52,9 +52,12 @@ final class ServerOnly10KRequestsBenchmark: Benchmark {
headers.add(name: ":authority", value: "localhost", indexing: .nonIndexable)
headers.add(name: ":path", value: "/", indexing: .indexable)
headers.add(name: ":scheme", value: "https", indexing: .indexable)
headers.add(name: "user-agent",
value: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
indexing: .nonIndexable)
headers.add(
name: "user-agent",
value:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
indexing: .nonIndexable
)
headers.add(name: "accept-encoding", value: "gzip, deflate", indexing: .indexable)
var hpackEncoder = HPACKEncoder(allocator: .init())
@@ -115,7 +118,7 @@ final class ServerOnly10KRequestsBenchmark: Benchmark {
func setUp() throws {
let channel = EmbeddedChannel()
_ = try channel.configureHTTP2Pipeline(mode: .server) { streamChannel -> EventLoopFuture<Void> in
return streamChannel.pipeline.addHandler(TestServer())
streamChannel.pipeline.addHandler(TestServer())
}.wait()
try channel.connect(to: .init(unixDomainSocketPath: "/fake"), promise: nil)
@@ -126,7 +129,7 @@ final class ServerOnly10KRequestsBenchmark: Benchmark {
initialBytes.writeImmutableBuffer(self.settingsACK)
try channel.writeInbound(initialBytes)
while try channel.readOutbound(as: ByteBuffer.self) != nil { }
while try channel.readOutbound(as: ByteBuffer.self) != nil {}
self.channel = channel
}
@@ -149,7 +152,7 @@ final class ServerOnly10KRequestsBenchmark: Benchmark {
private func sendInterleavedRequests(_ interleavedRequests: Int) throws -> Int {
var streamID = self.streamID
for _ in 0 ..< interleavedRequests {
for _ in 0..<interleavedRequests {
self.headersFrame.setInteger(UInt32(Int32(streamID)), at: self.headersFrame.readerIndex + 5)
try self.channel!.writeInbound(self.headersFrame)
streamID = streamID.advanced(by: 2)
@@ -157,7 +160,7 @@ final class ServerOnly10KRequestsBenchmark: Benchmark {
streamID = self.streamID
for _ in 0 ..< interleavedRequests {
for _ in 0..<interleavedRequests {
self.dataFrame.setInteger(UInt32(Int32(streamID)), at: self.dataFrame.readerIndex + 5)
try self.channel!.writeInbound(self.dataFrame)
streamID = streamID.advanced(by: 2)
@@ -176,7 +179,7 @@ final class ServerOnly10KRequestsBenchmark: Benchmark {
}
}
fileprivate class TestServer: ChannelInboundHandler {
private class TestServer: ChannelInboundHandler {
public typealias InboundIn = HTTP2Frame.FramePayload
public typealias OutboundOut = HTTP2Frame.FramePayload
@@ -27,9 +27,12 @@ final class StreamTeardownBenchmark: Benchmark {
headers.add(name: ":authority", value: "localhost", indexing: .nonIndexable)
headers.add(name: ":path", value: "/", indexing: .indexable)
headers.add(name: ":scheme", value: "https", indexing: .indexable)
headers.add(name: "user-agent",
value: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
indexing: .nonIndexable)
headers.add(
name: "user-agent",
value:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
indexing: .nonIndexable
)
headers.add(name: "accept-encoding", value: "gzip, deflate", indexing: .indexable)
var hpackEncoder = HPACKEncoder(allocator: .init())
@@ -87,14 +90,14 @@ final class StreamTeardownBenchmark: Benchmark {
self.concurrentStreams = concurrentStreams
}
func setUp() { }
func setUp() {}
func tearDown() { }
func tearDown() {}
func createChannel() throws -> EmbeddedChannel {
let channel = EmbeddedChannel()
_ = try channel.configureHTTP2Pipeline(mode: .server) { streamChannel -> EventLoopFuture<Void> in
return streamChannel.pipeline.addHandler(DoNothingServer())
streamChannel.pipeline.addHandler(DoNothingServer())
}.wait()
try channel.pipeline.addHandler(SendGoawayHandler(expectedStreams: self.concurrentStreams)).wait()
@@ -106,7 +109,7 @@ final class StreamTeardownBenchmark: Benchmark {
initialBytes.writeImmutableBuffer(self.settingsACK)
try channel.writeInbound(initialBytes)
while try channel.readOutbound(as: ByteBuffer.self) != nil { }
while try channel.readOutbound(as: ByteBuffer.self) != nil {}
return channel
}
@@ -127,10 +130,13 @@ final class StreamTeardownBenchmark: Benchmark {
return bodyByteCount
}
private func sendInterleavedRequestsAndTerminate(_ interleavedRequests: Int, _ channel: EmbeddedChannel) throws -> Int {
private func sendInterleavedRequestsAndTerminate(
_ interleavedRequests: Int,
_ channel: EmbeddedChannel
) throws -> Int {
var streamID = HTTP2StreamID(1)
for _ in 0 ..< interleavedRequests {
for _ in 0..<interleavedRequests {
self.headersFrame.setInteger(UInt32(Int32(streamID)), at: self.headersFrame.readerIndex + 5)
try channel.writeInbound(self.headersFrame)
streamID = streamID.advanced(by: 2)
@@ -148,17 +154,18 @@ final class StreamTeardownBenchmark: Benchmark {
}
}
fileprivate class DoNothingServer: ChannelInboundHandler {
private class DoNothingServer: ChannelInboundHandler {
public typealias InboundIn = HTTP2Frame.FramePayload
public typealias OutboundOut = HTTP2Frame.FramePayload
}
fileprivate class SendGoawayHandler: ChannelInboundHandler {
private class SendGoawayHandler: ChannelInboundHandler {
public typealias InboundIn = HTTP2Frame
public typealias OutboundOut = HTTP2Frame
private static let goawayFrame: HTTP2Frame = HTTP2Frame(
streamID: .rootStream, payload: .goAway(lastStreamID: .rootStream, errorCode: .enhanceYourCalm, opaqueData: nil)
streamID: .rootStream,
payload: .goAway(lastStreamID: .rootStream, errorCode: .enhanceYourCalm, opaqueData: nil)
)
private let expectedStreams: Int
+91 -29
View File
@@ -12,19 +12,21 @@
//
//===----------------------------------------------------------------------===//
import Foundation
import Dispatch
import Foundation
// MARK: Test Harness
var _warning: String = ""
assert({
print("======================================================")
print("= YOU ARE RUNNING NIOPerformanceTester IN DEBUG MODE =")
print("======================================================")
_warning = " <<< DEBUG MODE >>>"
return true
}())
assert(
{
print("======================================================")
print("= YOU ARE RUNNING NIOPerformanceTester IN DEBUG MODE =")
print("======================================================")
_warning = " <<< DEBUG MODE >>>"
return true
}()
)
let warning = _warning
public func measure(_ fn: () throws -> Int) rethrows -> [TimeInterval] {
@@ -35,7 +37,7 @@ public func measure(_ fn: () throws -> Int) rethrows -> [TimeInterval] {
return end.timeIntervalSince(start)
}
_ = try measureOne(fn) /* pre-heat and throw away */
_ = try measureOne(fn) // pre-heat and throw away
var measurements = Array(repeating: 0.0, count: 10)
for i in 0..<10 {
measurements[i] = try measureOne(fn)
@@ -46,7 +48,7 @@ public func measure(_ fn: () throws -> Int) rethrows -> [TimeInterval] {
let limitSet = ProcessInfo.processInfo.arguments.dropFirst()
public func measureAndPrint(desc: String, fn: () throws -> Int) rethrows -> Void {
public func measureAndPrint(desc: String, fn: () throws -> Int) rethrows {
#if CACHEGRIND
// When CACHEGRIND is set we only run a single requested test, and we only run it once. No printing or other mess.
if limitSet.contains(desc) {
@@ -76,29 +78,89 @@ func measureAndPrint<B: Benchmark>(desc: String, benchmark bench: @autoclosure (
bench.tearDown()
}
try measureAndPrint(desc: desc) {
return try bench.run()
try bench.run()
}
}
// MARK: Utilities
try measureAndPrint(desc: "1_conn_10k_reqs", benchmark: Bench1Conn10kRequests())
try measureAndPrint(desc: "encode_100k_header_blocks_indexable", benchmark: HPACKHeaderEncodingBenchmark(headers: .indexable, loopCount: 100_000))
try measureAndPrint(desc: "encode_100k_header_blocks_nonindexable", benchmark: HPACKHeaderEncodingBenchmark(headers: .nonIndexable, loopCount: 100_000))
try measureAndPrint(desc: "encode_100k_header_blocks_neverIndexed", benchmark: HPACKHeaderEncodingBenchmark(headers: .neverIndexed, loopCount: 100_000))
try measureAndPrint(desc: "decode_100k_header_blocks_indexable", benchmark: HPACKHeaderDecodingBenchmark(headers: .indexable, loopCount: 100_000))
try measureAndPrint(desc: "decode_100k_header_blocks_nonindexable", benchmark: HPACKHeaderDecodingBenchmark(headers: .nonIndexable, loopCount: 100_000))
try measureAndPrint(desc: "decode_100k_header_blocks_neverIndexed", benchmark: HPACKHeaderDecodingBenchmark(headers: .neverIndexed, loopCount: 100_000))
try measureAndPrint(
desc: "encode_100k_header_blocks_indexable",
benchmark: HPACKHeaderEncodingBenchmark(headers: .indexable, loopCount: 100_000)
)
try measureAndPrint(
desc: "encode_100k_header_blocks_nonindexable",
benchmark: HPACKHeaderEncodingBenchmark(headers: .nonIndexable, loopCount: 100_000)
)
try measureAndPrint(
desc: "encode_100k_header_blocks_neverIndexed",
benchmark: HPACKHeaderEncodingBenchmark(headers: .neverIndexed, loopCount: 100_000)
)
try measureAndPrint(
desc: "decode_100k_header_blocks_indexable",
benchmark: HPACKHeaderDecodingBenchmark(headers: .indexable, loopCount: 100_000)
)
try measureAndPrint(
desc: "decode_100k_header_blocks_nonindexable",
benchmark: HPACKHeaderDecodingBenchmark(headers: .nonIndexable, loopCount: 100_000)
)
try measureAndPrint(
desc: "decode_100k_header_blocks_neverIndexed",
benchmark: HPACKHeaderDecodingBenchmark(headers: .neverIndexed, loopCount: 100_000)
)
try measureAndPrint(desc: "hpackheaders_canonical_form", benchmark: HPACKHeaderCanonicalFormBenchmark(.noTrimming))
try measureAndPrint(desc: "hpackheaders_canonical_form_trimming_whitespace", benchmark: HPACKHeaderCanonicalFormBenchmark(.trimmingWhitespace))
try measureAndPrint(desc: "hpackheaders_canonical_form_trimming_whitespace_short_strings", benchmark: HPACKHeaderCanonicalFormBenchmark(.trimmingWhitespaceFromShortStrings))
try measureAndPrint(desc: "hpackheaders_canonical_form_trimming_whitespace_long_strings", benchmark: HPACKHeaderCanonicalFormBenchmark(.trimmingWhitespaceFromLongStrings))
try measureAndPrint(desc: "hpackheaders_normalize_httpheaders_removing_10k_conn_headers", benchmark: HPACKHeadersNormalizationOfHTTPHeadersBenchmark(headersKind: .manyUniqueConnectionHeaderValues(10_000), iterations: 10))
try measureAndPrint(desc: "hpackheaders_normalize_httpheaders_keeping_10k_conn_headers", benchmark: HPACKHeadersNormalizationOfHTTPHeadersBenchmark(headersKind: .manyConnectionHeaderValuesWhichAreNotRemoved(10_000), iterations: 10))
try measureAndPrint(desc: "huffman_encode_basic", benchmark: HuffmanEncodingBenchmark(huffmanString: .basicHuffmanString, loopCount: 100))
try measureAndPrint(desc: "huffman_encode_complex", benchmark: HuffmanEncodingBenchmark(huffmanString: .complexHuffmanString, loopCount: 100))
try measureAndPrint(desc: "huffman_decode_basic", benchmark: HuffmanDecodingBenchmark(huffmanBytes: .basicHuffmanBytes, loopCount: 25))
try measureAndPrint(desc: "huffman_decode_complex", benchmark: HuffmanDecodingBenchmark(huffmanBytes: .complexHuffmanBytes, loopCount: 10))
try measureAndPrint(desc: "server_only_10k_requests_1_concurrent", benchmark: ServerOnly10KRequestsBenchmark(concurrentStreams: 1))
try measureAndPrint(desc: "server_only_10k_requests_100_concurrent", benchmark: ServerOnly10KRequestsBenchmark(concurrentStreams: 100))
try measureAndPrint(desc: "stream_teardown_10k_requests_100_concurrent", benchmark: StreamTeardownBenchmark(concurrentStreams: 100))
try measureAndPrint(
desc: "hpackheaders_canonical_form_trimming_whitespace",
benchmark: HPACKHeaderCanonicalFormBenchmark(.trimmingWhitespace)
)
try measureAndPrint(
desc: "hpackheaders_canonical_form_trimming_whitespace_short_strings",
benchmark: HPACKHeaderCanonicalFormBenchmark(.trimmingWhitespaceFromShortStrings)
)
try measureAndPrint(
desc: "hpackheaders_canonical_form_trimming_whitespace_long_strings",
benchmark: HPACKHeaderCanonicalFormBenchmark(.trimmingWhitespaceFromLongStrings)
)
try measureAndPrint(
desc: "hpackheaders_normalize_httpheaders_removing_10k_conn_headers",
benchmark: HPACKHeadersNormalizationOfHTTPHeadersBenchmark(
headersKind: .manyUniqueConnectionHeaderValues(10_000),
iterations: 10
)
)
try measureAndPrint(
desc: "hpackheaders_normalize_httpheaders_keeping_10k_conn_headers",
benchmark: HPACKHeadersNormalizationOfHTTPHeadersBenchmark(
headersKind: .manyConnectionHeaderValuesWhichAreNotRemoved(10_000),
iterations: 10
)
)
try measureAndPrint(
desc: "huffman_encode_basic",
benchmark: HuffmanEncodingBenchmark(huffmanString: .basicHuffman, loopCount: 100)
)
try measureAndPrint(
desc: "huffman_encode_complex",
benchmark: HuffmanEncodingBenchmark(huffmanString: .complexHuffman, loopCount: 100)
)
try measureAndPrint(
desc: "huffman_decode_basic",
benchmark: HuffmanDecodingBenchmark(huffmanBytes: .basicHuffmanBytes, loopCount: 25)
)
try measureAndPrint(
desc: "huffman_decode_complex",
benchmark: HuffmanDecodingBenchmark(huffmanBytes: .complexHuffmanBytes, loopCount: 10)
)
try measureAndPrint(
desc: "server_only_10k_requests_1_concurrent",
benchmark: ServerOnly10KRequestsBenchmark(concurrentStreams: 1)
)
try measureAndPrint(
desc: "server_only_10k_requests_100_concurrent",
benchmark: ServerOnly10KRequestsBenchmark(concurrentStreams: 100)
)
try measureAndPrint(
desc: "stream_teardown_10k_requests_100_concurrent",
benchmark: StreamTeardownBenchmark(concurrentStreams: 100)
)