diff --git a/README.md b/README.md index 887bc23..eb0b6f9 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ There are three classes of benchmarks: | | | tree.jl | Small pointer-heavy data structure. | | | strings | strings.jl | | | Multithreaded | binary_tree | tree_immutable.jl | Small pointer-heavy data structure. | -| | | tree_mutable.jl | Small pointer-heavy data structure. | +| | | tree_mutable.jl | Small pointer-heavy data structure. | +| | bigarrays | objarray.jl | Large arrays with pointer elements | +| | small_array | alloc_alot.jl | Lots of malloc backed arrays | +| | bigint | pollardt.jl | Tests small `BigInt`s but threaded. | | Slow | rb\_tree | rb\_tree.jl | Pointer graph whose minimum linear arrangement has cost Θ(n²). | | | pidigits.jl | Tests large `BigInt`s. | diff --git a/benches/multithreaded/bigint/Project.toml b/benches/multithreaded/bigint/Project.toml new file mode 100644 index 0000000..81648c0 --- /dev/null +++ b/benches/multithreaded/bigint/Project.toml @@ -0,0 +1 @@ +[deps] diff --git a/benches/multithreaded/bigint/pollardt.jl b/benches/multithreaded/bigint/pollardt.jl new file mode 100644 index 0000000..f9e3998 --- /dev/null +++ b/benches/multithreaded/bigint/pollardt.jl @@ -0,0 +1,44 @@ +include(joinpath("..", "..", "..", "utils.jl")) + +function pollardfactor(n::T=big(1208925819691594988651321)) where {T<:Integer} + for c in T(1):(n-3) + G, r, q = ones(T, 3) + y = 2 + m::T = 1900 + ys::T = 0 + x::T = 0 + while G == 1 + x = y + for i in 1:r + y = (y^2 + c) % n + end + k = T(0) + G = T(1) + while k < r && G == 1 + for i in 1:min(r - k, m) + ys = y + y = (y^2 + c) % n + q = (q * abs(x - y)) % n + end + G = gcd(q, n) + k += m + end + r *= 2 + end + G == n && (G = T(1)) + while G == 1 + ys = (ys^2 + c) % n + G = gcd(abs(x - ys), n) + end + if G != n + return G + end + end +end + +function threadfun() + Threads.@threads for i in 1:8 + pollardfactor() + end +end +@gctime threadfun() diff --git a/benches/multithreaded/small_arrays/Project.toml b/benches/multithreaded/small_arrays/Project.toml new file mode 100644 index 0000000..81648c0 --- /dev/null +++ b/benches/multithreaded/small_arrays/Project.toml @@ -0,0 +1 @@ +[deps] diff --git a/benches/multithreaded/small_arrays/alloc_alot.jl b/benches/multithreaded/small_arrays/alloc_alot.jl new file mode 100644 index 0000000..c5b22c1 --- /dev/null +++ b/benches/multithreaded/small_arrays/alloc_alot.jl @@ -0,0 +1,14 @@ +include(joinpath("..", "..", "..", "utils.jl")) + +const N = 2500 +a = Vector{Vector{Float64}}(undef, N) + +function alloc_alot() + for j in 1:1000 + Threads.@threads for i in 1:N + a[i] = rand(2500) + end + end +end + +@gctime alloc_alot()