Skip to content

Commit 4837e1e

Browse files
committed
add basic file for benchmarking
1 parent 79e4cac commit 4837e1e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

benchmarks/parallel_vs_serial.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#=
2+
This file benchmarks the parallel and serial computation of a recurrence matrix
3+
=#
4+
using DynamicalSystemsBase, RecurrenceAnalysis
5+
using Statistics, BenchmarkTools, Base.Threads
6+
7+
Ns = round.(Int, 10.0 .^ (2:0.5:4.5))
8+
ro = Systems.roessler()
9+
10+
println("I am using $(nthreads()) threads. I am reporting results as:")
11+
println("time of (parallel/serial) for 3D and 1D trajectories.")
12+
for N in Ns
13+
tr = trajectory(ro, N*0.1; dt = 0.1, Tr = 10.0)
14+
println("For N = $(length(tr))...")
15+
x = tr[:, 1]
16+
b_serial = @benchmark RecurrenceMatrix($(tr), 5.0; metric = Euclidean(), parallel = false)
17+
b_parallel = @benchmark RecurrenceMatrix($(tr), 5.0; metric = Euclidean(), parallel = true)
18+
b_s_1 = @benchmark RecurrenceMatrix($(x), 2.0; parallel = false)
19+
b_p_1 = @benchmark RecurrenceMatrix($(x), 2.0; parallel = true)
20+
threeD = median(b_serial.times)/median(b_parallel.times)
21+
oneD = median(b_s_1.times)/median(b_p_1.times)
22+
threeD, oneD = round.((threeD, oneD); sigdigits = 3)
23+
println("3D=$(threeD), 1D=$(oneD)")
24+
end

0 commit comments

Comments
 (0)