Skip to content

Commit

Permalink
Don’t use DocumentReader for PerfTests anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianfett committed Jul 22, 2020
1 parent 951a0d3 commit c15d1b3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions PerfTests/Sources/CodingPerfTests/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,25 @@ let sampleData = sampleString.data(using: .utf8)!

let reading = timing(name: "PureSwift on [UInt8] ") {
for _ in 1 ... runs {
var reader = DocumentReader(bytes: sampleBytes)
while let _ = reader.read() {}
var iterator = sampleBytes.makeIterator()
while let _ = iterator.next() {}
}
}

let readingFoundationData = timing(name: "PureSwift on Foundation.Data ") {
for _ in 1 ... runs {
var reader = DocumentReader(bytes: sampleData)
while let _ = reader.read() {}
var iterator = sampleData.makeIterator()
while let _ = iterator.next() {}
}
}

let readingNIOByteBuffer = timing(name: "PureSwift on NIO.ByteBuffer ") {
for _ in 1 ... runs {
var buffer = ByteBufferAllocator().buffer(capacity: sampleBytes.count)
buffer.writeBytes(sampleBytes)
var reader = DocumentReader(bytes: buffer.readBytes(length: buffer.readableBytes)!)
while let _ = reader.read() {}

var iterator = buffer.readableBytesView.makeIterator()
while let _ = iterator.next() {}
}
}

Expand Down

0 comments on commit c15d1b3

Please sign in to comment.