Skip to content

Add Benchmarks for metrics #106

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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 .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ jobs:
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable"

benchmarks:
name: Benchmarks
# Workaround https://github.com/nektos/act/issues/1875
uses: apple/swift-nio/.github/workflows/benchmarks.yml@main
with:
benchmark_package_path: "Benchmarks"

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
18 changes: 14 additions & 4 deletions Benchmarks/Benchmarks/PrometheusBenchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//

import Benchmark
import Foundation
import Prometheus

let registry = PrometheusCollectorRegistry()
Expand All @@ -27,9 +28,17 @@ public func makeLabels(_ idx: Int) -> [(String, String)] {
}

let benchmarks = {
Benchmark.defaultConfiguration.maxDuration = .seconds(5)
Benchmark.defaultConfiguration.scalingFactor = .kilo
Benchmark.defaultConfiguration.metrics = [.mallocCountTotal]
let ciMetrics: [BenchmarkMetric] = [
.mallocCountTotal,
]
let localMetrics = BenchmarkMetric.default

Benchmark.defaultConfiguration = .init(
metrics: ProcessInfo.processInfo.environment["CI"] != nil ? ciMetrics : localMetrics,
warmupIterations: 10,
scalingFactor: .kilo,
maxDuration: .seconds(5),
)

Benchmark("Counter - setup and increment") { benchmark in
runCounterBench(benchmark.scaledIterations)
Expand All @@ -52,7 +61,8 @@ let benchmarks = {
}

Benchmark("RegistryEmit - 5000 metrics",
configuration: .init(scalingFactor: .one)) { benchmark, run in
configuration: .init(scalingFactor: .one))
{ benchmark, run in
for _ in benchmark.scaledIterations {
run()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public func setupRegistryExport(numberOfMetrics: Int) -> () -> Void {
gaugeArray.reserveCapacity(numberOfMetrics)
buffer.reserveCapacity(counterExportSize)

for i in 0..<(numberOfMetrics / 2) {
for i in 0 ..< (numberOfMetrics / 2) {
let counter = registryExport.makeCounter(name: "http_requests_total", labels: makeLabels(i))
counter.increment()
counterArray.append(counter)
Expand Down
4 changes: 2 additions & 2 deletions Benchmarks/Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftPrometheus open source project
Expand All @@ -22,7 +22,7 @@ let package = Package(
],
dependencies: [
.package(path: "../"),
.package(url: "https://github.com/ordo-one/package-benchmark.git", from: "1.11.2"),
.package(url: "https://github.com/ordo-one/package-benchmark.git", from: "1.29.0"),
],
targets: [
.executableTarget(
Expand Down
41 changes: 0 additions & 41 deletions dev/update-benchmark-tresholds.sh

This file was deleted.

27 changes: 0 additions & 27 deletions docker/docker-compose.2204.510.yaml

This file was deleted.

Loading