Skip to content

Commit 57a4ce8

Browse files
committed
CI runs only malloc
1 parent 41a67dd commit 57a4ce8

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Benchmarks/Benchmarks/PrometheusBenchmarks/Benchmarks.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Benchmark
16+
import Foundation
1617
import Prometheus
1718

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

2930
let benchmarks = {
30-
Benchmark.defaultConfiguration.maxDuration = .seconds(5)
31-
Benchmark.defaultConfiguration.scalingFactor = .kilo
32-
Benchmark.defaultConfiguration.metrics = [.mallocCountTotal]
31+
let ciMetrics: [BenchmarkMetric] = [
32+
.mallocCountTotal,
33+
]
34+
let localMetrics = BenchmarkMetric.default
35+
36+
Benchmark.defaultConfiguration = .init(
37+
metrics: ProcessInfo.processInfo.environment["CI"] != nil ? ciMetrics : localMetrics,
38+
warmupIterations: 10,
39+
scalingFactor: .kilo,
40+
maxDuration: .seconds(5),
41+
)
3342

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

5463
Benchmark("RegistryEmit - 5000 metrics",
55-
configuration: .init(scalingFactor: .one)) { benchmark, run in
64+
configuration: .init(scalingFactor: .one))
65+
{ benchmark, run in
5666
for _ in benchmark.scaledIterations {
5767
run()
5868
}

Benchmarks/Benchmarks/PrometheusBenchmarks/RegistryEmit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public func setupRegistryExport(numberOfMetrics: Int) -> () -> Void {
2727
gaugeArray.reserveCapacity(numberOfMetrics)
2828
buffer.reserveCapacity(counterExportSize)
2929

30-
for i in 0..<(numberOfMetrics / 2) {
30+
for i in 0 ..< (numberOfMetrics / 2) {
3131
let counter = registryExport.makeCounter(name: "http_requests_total", labels: makeLabels(i))
3232
counter.increment()
3333
counterArray.append(counter)

0 commit comments

Comments
 (0)