Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more benchmarks #69

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
1 change: 1 addition & 0 deletions benches/multithreaded/bigint/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[deps]
44 changes: 44 additions & 0 deletions benches/multithreaded/bigint/pollardt.jl
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions benches/multithreaded/small_arrays/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[deps]
14 changes: 14 additions & 0 deletions benches/multithreaded/small_arrays/alloc_alot.jl
Original file line number Diff line number Diff line change
@@ -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()