Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dn loop bound box benchmark #2778

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Benchmarks/Benchmarks/NIOCoreBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ let benchmarks = {
blackHole(asyncChanel)
}
}

Benchmark(
"NIOLoopBoundBox.value",
configuration: .init(metrics: defaultMetrics, scalingFactor: .kilo)
) { benchmark in
runNIOLoopBoundBoxInPlaceMutation(benchmark: benchmark)
}
}
35 changes: 35 additions & 0 deletions Benchmarks/Benchmarks/NIOCoreBenchmarks/NIOLoopBoundBox.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2024 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 NIOCore
import NIOEmbedded
import Benchmark

func runNIOLoopBoundBoxInPlaceMutation(benchmark: Benchmark) {
let embeddedEventLoop = EmbeddedEventLoop()
let boundBox = NIOLoopBoundBox([Int](), eventLoop: embeddedEventLoop)
boundBox.value.reserveCapacity(1)

benchmark.startMeasurement()

for _ in benchmark.scaledIterations {
boundBox.value.removeAll(keepingCapacity: true)
boundBox.value.append(1)
}

benchmark.stopMeasurement()

precondition(boundBox.value.count == 1)
precondition(boundBox.value.reduce(0, +) == 1)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 0
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
}
"mallocCountTotal" : 90
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164212
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 0
}
4 changes: 2 additions & 2 deletions Benchmarks/Thresholds/5.8/NIOPosixBenchmarks.TCPEcho.p90.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 110
}
"mallocCountTotal" : 92
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 0
}
4 changes: 2 additions & 2 deletions Benchmarks/Thresholds/5.9/NIOPosixBenchmarks.TCPEcho.p90.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 110
}
"mallocCountTotal" : 92
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 164000
}
"mallocCountTotal" : 164216
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 0
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
}
"mallocCountTotal" : 90
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164210
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 10
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mallocCountTotal" : 0
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 108
}
"mallocCountTotal" : 90
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"mallocCountTotal" : 165000
}
"mallocCountTotal" : 164206
}
Loading