Skip to content

Commit

Permalink
Update benchmark
Browse files Browse the repository at this point in the history
Updated the benchmark to check across problem sizes, 2D vs 3D as well as single vs multi-threaded. Compute time per time step is linear with length(u). Multi-threading on my machine gives a 2x speedup, except for very small jobs.
  • Loading branch information
Gabe Weymouth committed Mar 26, 2023
1 parent 9973009 commit ff68c54
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ julia = "^1.5"
[extras]
AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
PerformanceTestTools = "dc46b164-d16f-48ec-a853-60448fc869fe"
Expand Down
33 changes: 27 additions & 6 deletions benchmark/flowcases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,35 @@ end
# end

# Benchmark
using BenchmarkTools
using BenchmarkTools,DataFrames,CSV
function benchmark_sim(sim)
sim_step!(sim,1)
sim_step!(sim,0.1)
WaterLily.DISABLE_PUSH()
@btime mom_step!(sim2.flow,sim2.pois) setup=(sim2=$sim) seconds=20
a = @benchmark mom_step!(sim2.flow,sim2.pois) setup=(sim2=$sim) seconds=20 samples=1000
WaterLily.ENABLE_PUSH()
a = minimum(a)
b = Dict(key => getfield(a, key) for key in propertynames(a))
b[:n] = length(sim.flow.u)
return b
end
begin
sim = sphere_example(16,false);
benchmark_sim(sim)
function create_CSV(N,twoD)
df = DataFrame((@show n;benchmark_sim(sphere_example(n,twoD))) for n N)
select!(df,Not([:params]))
CSV.write("benchmark\\threads"*string(Threads.nthreads())*"_2D"*string(twoD)*".csv",df)
end
create_CSV(2 .^ (3:8),true)
create_CSV(2 .^ (3:6),false)

begin
using Plots
plot(xaxis=("length u",:log10), yaxis=("time (ns)",:log10))
df = DataFrame(CSV.File("benchmark\\threads1_2Dtrue.csv"))
scatter!(df.n,df.time,label="2D, single threaded")
df = DataFrame(CSV.File("benchmark\\threads20_2Dtrue.csv"))
scatter!(df.n,df.time,label="2D, multi-threaded")
df = DataFrame(CSV.File("benchmark\\threads1_2Dfalse.csv"))
scatter!(df.n,df.time,label="3D, single threaded")
df = DataFrame(CSV.File("benchmark\\threads20_2Dfalse.csv"))
scatter!(df.n,df.time,label="3D, multi-threaded")
savefig("benchmark\\benchmark.png")
end

0 comments on commit ff68c54

Please sign in to comment.