-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathmultigraph_creation.exs
More file actions
35 lines (32 loc) · 894 Bytes
/
multigraph_creation.exs
File metadata and controls
35 lines (32 loc) · 894 Bytes
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
defmodule MultigraphCreationBench.Helpers do
def build_edges(size) do
labels = Enum.map(1..10, fn i -> :"label_#{i}" end)
for i <- 1..size do
v1 = :rand.uniform(div(size, 5))
v2 = :rand.uniform(div(size, 5))
label = Enum.random(labels)
{v1, v2, label: label, weight: :rand.uniform(100)}
end
end
end
alias MultigraphCreationBench.Helpers
Benchee.run(
%{
"plain graph (no index)" => fn edges ->
Enum.reduce(edges, Graph.new(), fn {v1, v2, opts}, g ->
Graph.add_edge(g, v1, v2, opts)
end)
end,
"multigraph (indexed)" => fn edges ->
Enum.reduce(edges, Graph.new(multigraph: true), fn {v1, v2, opts}, g ->
Graph.add_edge(g, v1, v2, opts)
end)
end
},
inputs: %{
"10k edges" => Helpers.build_edges(10_000),
"100k edges" => Helpers.build_edges(100_000)
},
time: 10,
memory_time: 5
)