Peter Adams 0f878f95f0
Performance testing for NIO PCAP logging (#98)
Motivation:

It's useful to know the overhead we could be adding by including
the PCAP handler.

Modifications:

Add a new executable based on the NIO performance testing executable.

Result:

There is a new executable which runs a short test of sending and receiving
data through the HTTP/1 handler using multiple eventloops and showing
three options.
1) Vanilla
2) With in memory PCAP never written to disk
3) With a disk based PCAP.
2020-08-03 12:13:24 +01:00

48 lines
1.8 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2020 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import NIO
import NIOExtras
import NIOHTTP1
import Foundation
// MARK: Setup
var warning: String = ""
assert({
print("============================================================")
print("= YOU ARE RUNNING NIOExtrasPerformanceTester IN DEBUG MODE =")
print("============================================================")
warning = " <<< DEBUG MODE >>>"
return true
}())
// MARK: Tests
// Test PCAP to file.
try! measureAndPrint(desc: "pcap_100k_reqs", benchmark: PCAPPerformanceTest(numberOfRepeats: 100_000))
// Test Rolling PCAP never writing to file.
try! measureAndPrint(desc: "rolling_pcap_100k_reqs", benchmark: RollingPCAPPerformanceTest(numberOfRepeats: 100_000))
// Relatively real world test - http1 with many threads.
try! measureAndPrint(desc: "http1_threaded_50reqs_500conns",
benchmark: HTTP1ThreadedRawPerformanceTest())
// Relatively real world test - http1 with many threads and rolling pcap.
try! measureAndPrint(desc: "http1_threaded_50reqs_500conns_rolling_pcap",
benchmark: HTTP1ThreadedRollingPCapPerformanceTest())
// Relatively real world test - http1 with many threads and pcap to file.
try! measureAndPrint(desc: "http1_threaded_50reqs_500conns_pcap",
benchmark: HTTP1ThreadedPCapPerformanceTest())