Hmm. The following looks like it regresses quite severely:
versioninfo()
#Julia Version 0.6.2
using BenchmarkTools
struct equalto_{T} <: Function
x::T
end
(eq_::equalto_{T})(y) where T = isequal(eq_.x, y)
V=[rand(UInt8, rand(0:255)) for i=1:1000];
Q=rand(UInt8, 1000);
function foolistsearch6(Q, V)
out = Vector{Int}(length(V))
for i=1:length(V)
pos = findfirst(equalto_(Q[i]), V[i])
if pos===0
out[i]=-1
else
out[i]=pos
end
end
out
end
@btime foolistsearch6(Q,V);
#115.033 ��s (1 allocation: 7.94 KiB)
Q=rand(UInt16, length(Q));
@btime foolistsearch6(Q,V);
#148.848 ��s (1 allocation: 7.94 KiB)
versioninfo()
#Julia Version 0.7.0-DEV.3666
#Commit 0f95988141* (2018-01-31 03:25 UTC)
using BenchmarkTools
V=[rand(UInt8, rand(0:255)) for i=1:1000];
Q=rand(UInt8, 1000);
function foolistsearch7(Q, V)
out = Vector{Int}(length(V))
for i=1:length(V)
pos = findfirst(equalto(Q[i]), V[i])
if pos===nothing
out[i]=-1
else
out[i]=pos
end
end
out
end
@btime foolistsearch7(Q,V)
154.900 ��s (88 allocations: 19.52 KiB)
Q=rand(UInt16, length(Q));
@btime foolistsearch7(Q,V)
287.831 ��s (88 allocations: 19.52 KiB)
I am not sure whether my example code simply sucks, or my example is badly chosen or whether this is due to the new handling.
They both are on 0.7. @foobar_lv2 — you have a deprecated method in your version 7 example. Changing Vector{Int}(length(V)) to Vector{Int}(uninitialized, length(V)) gives me nearly a 4x speed up.
Deprecations are slow. Fix that and 0.7 is way faster in my tests.
which is indeed way faster than 0.62. I hereby retract all my objections
PS at rddeits: You see from the versionstring that my 0.7 version was a master less than 48 hours old. I shall continue to post versioninfo() for all timings (master is moving so fast).