-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add benchmarks #103
base: main
Are you sure you want to change the base?
Add benchmarks #103
Conversation
IMO we should use static thresholds, like SwiftNIO does. package-benchmark relatively recently added a I think using something like this should work to compare static thresholds against current branch: swift package -c release --disable-sandbox \
benchmark thresholds check \
--path $PWD/Benchmarks/Thresholds/ \
--format markdown |
Benchmarks/Sources/Benchmarks.swift
Outdated
let boundary = "boundary123" | ||
var message = ArraySlice( | ||
""" | ||
--\(boundary)\r | ||
Content-Disposition: form-data; name="id"\r | ||
Content-Type: text/plain\r | ||
\r | ||
123e4567-e89b-12d3-a456-426655440000\r | ||
--\(boundary)\r | ||
Content-Disposition: form-data; name="address"\r | ||
Content-Type: application/json\r | ||
\r | ||
{\r | ||
"street": "3, Garden St",\r | ||
"city": "Hillsbery, UT"\r | ||
}\r | ||
--\(boundary)\r | ||
Content-Disposition: form-data; name="profileImage"; filename="image1.png"\r | ||
Content-Type: image/png\r | ||
\r\n | ||
""".utf8) | ||
|
||
message.append(contentsOf: Array(repeating: UInt8.random(in: 0...255), count: 500_000_000)) // 500MB | ||
message.append(contentsOf: "\r\n--\(boundary)--".utf8) | ||
|
||
let stream = AsyncStream { continuation in | ||
var offset = message.startIndex | ||
while offset < message.endIndex { | ||
let endIndex = min(message.endIndex, message.index(offset, offsetBy: 16)) | ||
continuation.yield(message[offset..<endIndex]) | ||
offset = endIndex | ||
} | ||
continuation.finish() | ||
} | ||
|
||
let sequence = StreamingMultipartParserAsyncSequence(boundary: boundary, buffer: stream) |
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.
Benchmark
accepts a setUp
closure IIRC. I'd personally just use a lazy variable to make sure the whole thing is only done once, regardless of how many iterations the benchmark is going to have.
The problem with this is we don't have any baseline thresholds (yet) |
PR benchmarks run at |
Benchmark Report❌ Pull request has significant performance differences 📊 Click to expand comparison resultBenchmark check running at 2025-01-10 16:48:19 UTCCould not find any matching absolute thresholds at path [/__w/multipart-kit/multipart-kit/Benchmarks/Thresholds/], failing threshold check. Click to expand benchmark resultBaseline benchmarks
ParserCollating Parser Allocations
Collating Parser Throughput
Streaming Parser Allocations
Streaming Parser Throughput
SerializerSerializer Allocations
Serializer Throughput
|
No description provided.