This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools | |
function bubble_sort(v::AbstractArray{T}) where T<:Real | |
for _ in 1:length(v)-1 | |
for i in 1:length(v)-1 | |
@inbounds if v[i] > v[i+1] | |
v[i], v[i+1] = v[i+1], v[i] | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unique_ids3(itr) | |
# create individual dictionaries for each thread, | |
# where keys have the type of itr's elements | |
d = [Dict{eltype(itr), Vector{Int}}() for _ in 1:Threads.nthreads()] | |
# iterate through itr, using automatic threading | |
# :static ensures that threadid() remains constant within an iteration | |
Threads.@threads :static for index in eachindex(itr) | |
id = Threads.threadid() | |
@inbounds val = itr[index] | |
# check if the dictionary |
OlderNewer