Skip to content

Commit

Permalink
do 1000x for cpu time
Browse files Browse the repository at this point in the history
  • Loading branch information
MahdiBM committed Jan 11, 2025
1 parent 8dbe4f1 commit 663ce3b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Benchmarks/Parser/Parser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import MultipartKit
// to simulate async work.
let benchmarks: @Sendable () -> Void = {
let boundary = "boundary123"
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 bigMessage = makeMessage(boundary: boundary, size: 1 << 24) // 400MiB: Big message
let bigMessageStream = makeParsingStream(for: bigMessage, chunkSize: 1 << 14) // 16KiB: Realistic streaming chunk size

Benchmark(
"StreamingParserAllocations",
Expand All @@ -23,12 +23,12 @@ let benchmarks: @Sendable () -> Void = {
}

Benchmark(
"StreamingParserCPUTime",
"1000xStreamingParserCPUTime",
configuration: .init(
metrics: [.cpuUser]
)
) { benchmark in
for _ in benchmark.scaledIterations {
for _ in benchmark.scaledIterations * 1000 {
let streamingSequence = StreamingMultipartParserAsyncSequence(boundary: boundary, buffer: bigMessageStream)
for try await element in streamingSequence {
blackHole(element)
Expand All @@ -51,12 +51,12 @@ let benchmarks: @Sendable () -> Void = {
}

Benchmark(
"CollatingParserCPUTime",
"1000xCollatingParserCPUTime",
configuration: .init(
metrics: [.cpuUser]
)
) { benchmark in
for _ in benchmark.scaledIterations {
for _ in benchmark.scaledIterations * 1000 {
let sequence = MultipartParserAsyncSequence(boundary: boundary, buffer: bigMessageStream)
for try await element in sequence {
blackHole(element)
Expand Down
4 changes: 2 additions & 2 deletions Benchmarks/Serializer/Serializer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ let benchmarks: @Sendable () -> Void = {
}

Benchmark(
"SerializerCPUTime",
"1000xSerializerCPUTime",
configuration: .init(
metrics: [.cpuUser]
)
) { benchmark in
for _ in benchmark.scaledIterations {
for _ in benchmark.scaledIterations * 1000 {
let serializer = MultipartSerializer(boundary: "boundary123")
let seriliazed = try serializer.serialize(parts: repeatedParts)
blackHole(seriliazed)
Expand Down

0 comments on commit 663ce3b

Please sign in to comment.