Skip to content

Commit 1a021f4

Browse files
committed
add benchmark cases in a separate file
1 parent 3227b97 commit 1a021f4

File tree

2 files changed

+120
-220
lines changed

2 files changed

+120
-220
lines changed

benchmark/benchmark_cases.jl

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"""
2+
BenchmarkCase
3+
4+
Represents a single benchmark case for NetworkDynamics.
5+
6+
Fields:
7+
- name: String identifier for the benchmark
8+
- constructor: Function that creates the Network for a given N
9+
- Ns: Vector of network sizes to benchmark
10+
- description: Documentation string
11+
"""
12+
struct BenchmarkCase
13+
name::String
14+
constructor::Function
15+
Ns::Vector{Int}
16+
description::String
17+
end
18+
19+
# Helper functions to reduce code duplication
20+
function make_ws_graph(N, k, β=0.0; rng=StableRNG(1))
21+
watts_strogatz(N, k, β; rng)
22+
end
23+
24+
function make_mixed_vertices(v1, v2, N; rng=StableRNG(1))
25+
vertex = [v1, v2]
26+
vertex[shuffle(rng, vcat([1 for _ in 1:N÷2], [2 for _ in 1:N÷2]))]
27+
end
28+
29+
# Standard benchmark cases
30+
const BENCHMARK_CASES = [
31+
BenchmarkCase(
32+
"diffusion_static_edge",
33+
N -> begin
34+
g = make_ws_graph(N, N ÷ 2)
35+
Network(g, diffusion_vertex(), diffusion_edge())
36+
end,
37+
[100, 300, 1000, 3000],
38+
"Diffusion network with static edges"
39+
),
40+
41+
BenchmarkCase(
42+
"diffusion_ode_edge",
43+
N -> begin
44+
g = make_ws_graph(N, N ÷ 2)
45+
Network(g, diffusion_vertex(), diffusion_dedge())
46+
end,
47+
[100, 300, 1000, 3000],
48+
"Diffusion network with ODE edges"
49+
),
50+
51+
BenchmarkCase(
52+
"kuramoto_homogeneous",
53+
N -> begin
54+
g = make_ws_graph(N, 3, 0.8)
55+
Network(g, kuramoto_vertex_2d(), static_kuramoto_edge())
56+
end,
57+
[100, 1_000, 10_000, 100_000],
58+
"Homogeneous Kuramoto oscillators"
59+
),
60+
61+
BenchmarkCase(
62+
"kuramoto_heterogeneous",
63+
N -> begin
64+
g = make_ws_graph(N, 3, 0.8)
65+
vertices = make_mixed_vertices(kuramoto_vertex_1d(), kuramoto_vertex_2d(), N)
66+
Network(g, vertices, static_kuramoto_edge())
67+
end,
68+
[100, 1_000, 10_000, 100_000],
69+
"Heterogeneous Kuramoto oscillators"
70+
),
71+
72+
BenchmarkCase(
73+
"powergrid",
74+
N -> begin
75+
g = make_ws_graph(N, 3, 0.8)
76+
vertices = make_mixed_vertices(pqnode(), generator(), N)
77+
Network(g, vertices, piline())
78+
end,
79+
[100, 1_000, 10_000, 100_000],
80+
"Power grid network with PQ nodes and generators"
81+
)
82+
]

0 commit comments

Comments
 (0)