Skip to content

Commit

Permalink
adjust benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Jan 11, 2025
1 parent 86b00c7 commit ad4c1c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Benchmarks/Parser/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ let benchmarks: @Sendable () -> Void = {
let bigMessage = makeMessage(boundary: boundary, size: 1 << 24) // 400MiB: Big message
let bigMessageStream = makeParsingStream(for: bigMessage, chunkSize: 1 << 14) // 16KiB: Realistic streaming chunk size

let streamingSequence = StreamingMultipartParserAsyncSequence(boundary: boundary, buffer: bigMessageStream)
let sequence = MultipartParserAsyncSequence(boundary: boundary, buffer: bigMessageStream)

Benchmark(
"StreamingParserAllocations",
configuration: .init(
metrics: [.mallocCountTotal]
)
) { benchmark in
for _ in benchmark.scaledIterations {
let streamingSequence = StreamingMultipartParserAsyncSequence(boundary: boundary, buffer: bigMessageStream)
for try await element in streamingSequence {
blackHole(element)
}
Expand All @@ -31,6 +29,7 @@ let benchmarks: @Sendable () -> Void = {
)
) { benchmark in
for _ in benchmark.scaledIterations {
let streamingSequence = StreamingMultipartParserAsyncSequence(boundary: boundary, buffer: bigMessageStream)
for try await element in streamingSequence {
blackHole(element)
}
Expand All @@ -44,6 +43,7 @@ let benchmarks: @Sendable () -> Void = {
)
) { benchmark in
for _ in benchmark.scaledIterations {
let sequence = MultipartParserAsyncSequence(boundary: boundary, buffer: bigMessageStream)
for try await element in sequence {
blackHole(element)
}
Expand All @@ -57,6 +57,7 @@ let benchmarks: @Sendable () -> Void = {
)
) { benchmark in
for _ in benchmark.scaledIterations {
let sequence = MultipartParserAsyncSequence(boundary: boundary, buffer: bigMessageStream)
for try await element in sequence {
blackHole(element)
}
Expand Down
6 changes: 4 additions & 2 deletions Benchmarks/Serializer/Serializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ let benchmarks: @Sendable () -> Void = {
)
) { benchmark in
for _ in benchmark.scaledIterations {
let seriliazed = try MultipartSerializer(boundary: "boundary123").serialize(parts: onePart)
let serializer = MultipartSerializer(boundary: "boundary123")
let seriliazed = try serializer.serialize(parts: onePart)
blackHole(seriliazed)
}
}
Expand All @@ -31,7 +32,8 @@ let benchmarks: @Sendable () -> Void = {
)
) { benchmark in
for _ in benchmark.scaledIterations {
let seriliazed = try MultipartSerializer(boundary: "boundary123").serialize(parts: repeatedParts)
let serializer = MultipartSerializer(boundary: "boundary123")
let seriliazed = try serializer.serialize(parts: repeatedParts)
blackHole(seriliazed)
}
}
Expand Down

0 comments on commit ad4c1c7

Please sign in to comment.