-
Notifications
You must be signed in to change notification settings - Fork 31
Consumer performance benchmark #140
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
Closed
blindspotbounty
wants to merge
12
commits into
swift-server:main
from
ordo-one:perf-consumer-benchmark
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7d19682
Add performance test for swift-kafka vs librdkafka
blindspotbounty 1a1eea2
mimic docker files
blindspotbounty 5bf4d02
use simmilar to nio benchmark structure
blindspotbounty e0219d0
add headers
blindspotbounty 907f0e1
add 'benchmark' docker target to show results
blindspotbounty acb54ab
approx structure for kafka test utils
blindspotbounty 684f104
revert testable
blindspotbounty 97f48a7
reduce metrics
blindspotbounty 0dbc3b8
add benchmark utils
blindspotbounty d0f077d
add producer and headers benchmarks, fix returned error from produce
blindspotbounty 790e081
add librdkafka producer with headers
blindspotbounty 1f69304
add consumer with headers
blindspotbounty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
Benchmarks/Benchmarks/SwiftKafkaBenchmarkUtils/Utilities.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the swift-kafka-client open source project | ||
// | ||
// Copyright (c) 2023 Apple Inc. and the swift-kafka-client project authors | ||
// Licensed under Apache License v2.0 | ||
// | ||
// See LICENSE.txt for license information | ||
// See CONTRIBUTORS.txt for the list of swift-kafka-client project authors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Crdkafka | ||
import Foundation | ||
import Kafka | ||
import KafkaTestUtils | ||
import Logging | ||
|
||
public extension Logger { | ||
static var testLogger: Logger { | ||
var logger = Logger(label: "bench_log") | ||
#if DEBUG | ||
logger.logLevel = .debug | ||
#else | ||
logger.logLevel = .info | ||
#endif | ||
return logger | ||
} | ||
} | ||
|
||
public let logger: Logger = .testLogger | ||
public let kafkaHost: String = kafkaHostFromEnv() | ||
public let kafkaPort: Int = kafkaPortFromEnv() | ||
public let numOfMessages: UInt = .init(getFromEnv("MESSAGES_NUMBER") ?? "500000")! | ||
|
||
|
||
public func benchLog(_ msg: @autoclosure () -> Logger.Message) { | ||
// Just in case for debug | ||
#if DEBUG | ||
logger.debug(msg()) | ||
#endif | ||
} | ||
|
||
public func getFromEnv(_ key: String) -> String? { | ||
ProcessInfo.processInfo.environment[key] | ||
} | ||
|
||
public func kafkaHostFromEnv() -> String { | ||
getFromEnv("KAFKA_HOST") ?? "localhost" | ||
} | ||
|
||
public func kafkaPortFromEnv() -> Int { | ||
.init(getFromEnv("KAFKA_PORT") ?? "9092")! | ||
} | ||
|
||
public func bootstrapBrokerAddress() -> KafkaConfiguration.BrokerAddress { | ||
.init( | ||
host: kafkaHost, | ||
port: kafkaPort | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need these utils? They seem like small overhead in the benchmarks themselves and I would rather have them defined there. Moreover I don't think we have to read anytime from the ENV. Let's just hardcode the ports etc.