Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/io/IOBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ const SUITE = BenchmarkGroup()
# read (#12364) #
#################

function perf_read!(io)
function perf_read!(io, ::Type{T}) where T
seekstart(io)
x = 0
x = zero(T)
while !(eof(io))
x += read(io, UInt8)
x += read(io, T)
end
return x
end

g = addgroup!(SUITE, "read", ["buffer", "stream", "string"])

testbuf = IOBuffer(randstring(RandUtils.SEED, 10^4))

g["read"] = @benchmarkable perf_read!($testbuf)
g["readstring"] = @benchmarkable read($testbuf, String)
g["read"] = @benchmarkable perf_read!(testbuf, UInt8) setup = testbuf = IOBuffer(randstring(RandUtils.SEED, 10^4))
g["readfloat64"] = @benchmarkable perf_read!(testbuf, Float64) setup = testbuf = IOBuffer(randstring(RandUtils.SEED, 10^4))
g["readstring"] = @benchmarkable read(testbuf, String) setup = testbuf = IOBuffer(randstring(RandUtils.SEED, 10^4))

#################################
# serialization (#18633, #7893) #
Expand Down