You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See this thread for context. Consider the following code (requires PR #141). message takes about 140 ns, while Message takes 3400 ns. Something like message should be available or the performance of Message should be made comparable for small payloads.
using ZMQ, BenchmarkTools
functionmessage(s)
b =IOBuffer()
write(b,s)
m =Message(b.size)
m[:]=b.data
m
end@benchmarkmessage("1")
@benchmarkMessage("1")
The text was updated successfully, but these errors were encountered:
I wrote a version of message with only one copy, which is a bit faster than the previous one. Then I benchmarked all 3 version (my two, plus ZMQ.Message) vs length of string. ZMQ.Message appears to win for strings longer than roughly 250 bytes. But I think there may be something else wrong, when I run the benchmark, it takes much longer to complete the portion for Message than for the other two versions, despite the fact that the sum of minimum times across all benchmarks is lower. Nonetheless, here is the plot I generated, followed by the code I used.
using ZMQ, BenchmarkTools, PyPlot
function Base.setindex!(m::Message, v, i::Integer)
@boundscheckif i <1|| i >length(m)
throw(BoundsError())
endunsafe_store!(pointer(m), v, i)
endfunctionmessage(x)
m =Message(sizeof(x))
mb = Base.AbstractIOBuffer(m,true,true,true,false,length(m))
write(mb,x)
m
endfunctionmessage_cp(s)
b =IOBuffer()
write(b,s)
m =Message(b.size)
m[:]=b.data
m
endfunctionbenchmark_length(f,l)
s =randstring(l)
b=@benchmark$f($s) evals=10minimum(b.times)
end
lengths =2.^(0:24)
message_mtimes = [benchmark_length(message,l) for l in lengths]
message_cp_mtimes = [benchmark_length(message_cp,l) for l in lengths]
Message_mtimes = [benchmark_length(Message,l) for l in lengths]
figure()
plot(lengths, message_mtimes, label="message")
plot(lengths, message_cp_mtimes, label="message_cp")
plot(lengths, Message_mtimes, label="Message")
xlabel("bytes")
ylabel("minimum time to construct (ns)")
legend(loc="best")
xscale("log")
yscale("log")
See this thread for context. Consider the following code (requires PR #141).
message
takes about 140 ns, whileMessage
takes 3400 ns. Something likemessage
should be available or the performance ofMessage
should be made comparable for small payloads.The text was updated successfully, but these errors were encountered: