Skip to content

Commit

Permalink
fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterwln committed Feb 8, 2024
1 parent f709811 commit efae863
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using BenchmarkTools
const SUITE = BenchmarkGroup()
include("graph_engine.jl")
include("model_creation.jl")
include("constraints_engine.jl")
SUITE["constraints_engine"] = benchmark_constraints_engine()
# include("constraints_engine.jl")
# SUITE["constraints_engine"] = benchmark_constraints_engine()
SUITE["graph_engine"] = benchmark_graph_engine()
SUITE["model_creation"] = benchmark_model_creation()
9 changes: 4 additions & 5 deletions benchmark/graph_engine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ function factor_node_creation()
x = GraphPPL.getorcreate!(model, ctx, :x, j)
end
y = GraphPPL.getorcreate!(model, ctx, :y, nothing)
SUITE["Create factor node with $i edges"] = @benchmarkable GraphPPL.make_node!(m, c, sum, $y, [$x]) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
SUITE["Create factor node with $i edges"] = @benchmarkable GraphPPL.make_node!(m, c, sum, $y, (in = $x,)) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
end
return SUITE
end

function add_n_nodes(n::Int, model, ctx)
for i in 1:n
GraphPPL.add_variable_node!(model, ctx, :x; index=i)
GraphPPL.add_variable_node!(model, ctx, :x, i)
end
end

Expand All @@ -43,14 +43,13 @@ function variable_node_creation()
SUITE = BenchmarkGroup(["node_creation"])
model = GraphPPL.create_model()
ctx = GraphPPL.getcontext(model)
SUITE["add_variable_node"] = @benchmarkable GraphPPL.add_variable_node!(m, c, :x) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
SUITE["add_variable_node"] = @benchmarkable GraphPPL.add_variable_node!(m, c, :x, nothing) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1

for j in 10 .^ range(1, stop=3)
j = convert(Int, j)
model = GraphPPL.create_model()
ctx = GraphPPL.getcontext(model)
x = GraphPPL.ResizableArray(GraphPPL.NodeLabel, Val(1))
ctx.vector_variables[:x] = x
x = GraphPPL.getorcreate!(model, ctx, :x, 1)
SUITE["add $j variable nodes"] = @benchmarkable add_n_nodes($j, m, c) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
SUITE["getorcreate $j variable nodes ascending"] = @benchmarkable getorcreate_n_nodes($j, m, c) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
SUITE["getorcreate $j variable nodes descending"] = @benchmarkable getorcreate_n_nodes($j, m, c; asc=false) setup=(m=deepcopy($model);c=deepcopy($ctx)) evals=1
Expand Down
1 change: 0 additions & 1 deletion benchmark/model_zoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ function create_longarray(n::Int)
ctx,
long_array,
= μ, σ = σ, depth=n);
__debug__ = false,
)
return model
end
Expand Down

0 comments on commit efae863

Please sign in to comment.