forked from JuliaDynamics/ABMFrameworksComparison
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbenchmark.jl
More file actions
51 lines (47 loc) · 1.55 KB
/
benchmark.jl
File metadata and controls
51 lines (47 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Pkg; Pkg.instantiate()
using Agents
using Test
using Statistics
using Random
# Does not use @benchmark, due to jobs being OOM killed for long-running models, with a higher maximum runtime to allow the required repetitions.
# enabling the gc between samples did not resolve this BenchmarkTools.DEFAULT_PARAMETERS.gcsample = false
# Runs each model SAMPLE_COUNT + 1 times, discarding the first timing (which includes compilation)
SAMPLE_COUNT = 10
SEED = 12
# Boids
Random.seed!(SEED)
times = []
for i in 0:SAMPLE_COUNT
(model, agent_step!, model_step!) = Models.flocking(
n_birds = 80000,
separation = 1,
cohere_factor = 0.03,
separate_factor = 0.015,
match_factor = 0.05,
visual_distance = 5.0,
extent = (400, 400),
seed = rand(Int),
)
step_stats = @timed step!(model, agent_step!, model_step!, 100)
if i > 0
append!(times, step_stats.time)
end
end
println("Agents.jl Flocking times (ms)", map(x -> x * 1e3, times))
println("Agents.jl Flocking (mean ms): ", (Statistics.mean(times)) * 1e3)
# Schelling
Random.seed!(SEED)
times = []
for i in 0:SAMPLE_COUNT
(model, agent_step!, model_step!) = Models.schelling(
griddims = (500, 500),
numagents = 200000,
seed = rand(Int),
)
step_stats = @timed step!(model, agent_step!, model_step!, 100)
if i > 0
append!(times, step_stats.time)
end
end
println("Agents.jl schelling times (ms)", map(x -> x * 1e3, times))
println("Agents.jl Schelling (mean ms): ", (Statistics.mean(times)) * 1e3)