-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Check why returning a vector of nodes is a lot faster (x3) using an AbstractTrees traversal directly compared to MultiScaleTreeGraph.traverse, even if we apply a function in the AbstractTrees traversal:
using MultiScaleTreeGraph, AbstractTrees, BenchmarkTools
test_AT(node) = collect(PreOrderDFS(node))
test_AT_fn(node) = map(x -> x, collect(PreOrderDFS(node)))
test_MTG1(node) = traverse(node, node -> node, type = Node{NodeMTG, Dict{Symbol, Any}})
function test_MTG2(node)
nodes = Node{NodeMTG, Dict{Symbol, Any}}[]
traverse!(node, node -> push!(nodes, node))
return nodes
end
mtg = VPalm.mtg_skeleton(parameters)
plant = Node(NodeMTG("/", "Plant", 1, 1))
last_parent = plant
for i in 1:100
node = Node(last_parent, NodeMTG(i==1 ? "/" : "<", "Segment", i, 2))
last_parent = node
end
@benchmark test_AT($plant) # 906 ns
@benchmark test_AT_fn($plant) # 1.1 us
@benchmark test_MTG1($plant) # 3.5 μs
@benchmark test_MTG2($plant) # 3.9 μsMaybe it comes from the filters? Do we check everytime that we have a filter or not (e.g. symbol = nothing)? And in the end the difference comes from the time spent checking on the filters?
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request