julia>
function roughhash(s::String)
n = sizeof(s)
if n >= 8
return unsafe_load(Ptr{UInt64}(pointer(s)))
else
h = zero(UInt64)
for i = 1:n
@inbounds h = (h << 8) | codeunit(s, i)
end
return h
end
end
julia> @btime roughhash($("asldfj;asdjfsa"))
3.473 ns (0 allocations: 0 bytes)
0x613b6a66646c7361
So, it is close to the 3ns you were hoping for.