Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmark scripts from ExclusiveTopology to benchmark folder #1019

Open
KnutAM opened this issue Jul 9, 2024 · 0 comments
Open

Add benchmark scripts from ExclusiveTopology to benchmark folder #1019

KnutAM opened this issue Jul 9, 2024 · 0 comments

Comments

@KnutAM
Copy link
Member

KnutAM commented Jul 9, 2024

Can you dump the benchmark code in the benchmark folder (here or separate PR)?

Originally posted by @termi-official in #974 (review)

Would be good to do, relevant scripts are here for ref. I'll try to find time to look into that, unless someone does it before me.

using Ferrite, BenchmarkTools
function sum_indices(nbh::AbstractMatrix)
    v = 0
    for nbs in nbh
        for n in nbs
            v += n[1] + n[2]
        end
    end
    return v
end

function sum_indices(top::ExclusiveTopology)
    v  = sum_indices(top.vertex_vertex_neighbor)
    v += sum_indices(top.edge_edge_neighbor)
    v += sum_indices(top.face_face_neighbor)
    return v
end
function sum_skeleton_facet_neighbors(top, grid)
    skeleton = Ferrite.facetskeleton(top, grid)
    v = 0
    for facetidx in skeleton
        v += sum(n[1] + n[2] for n in getneighborhood(top, grid, facetidx); init = 0)
    end
    return v
end

grid = generate_grid(Hexahedron, (10, 10, 10));
top = ExclusiveTopology(grid); # Compilation

@btime sum_indices($top); 
# Master: 55.700 μs (0 allocations: 0 bytes)
#     PR: 36.000 μs (0 allocations: 0 bytes)
Ferrite.facetskeleton(top, grid); # Compilation

grid = generate_grid(Hexahedron, (100, 100, 100));
@time top = ExclusiveTopology(grid);
# Master: 27.150434 seconds (64.58 M allocations: 7.195 GiB, 72.43% gc time)
#     PR:  3.799651 seconds (45 allocations: 1.895 GiB, 13.84% gc time)
@time Ferrite.facetskeleton(top, grid);
# Master: 0.143506 seconds (2 allocations: 46.234 MiB)
#     PR: 0.032492 seconds (2 allocations: 46.234 MiB)
@btime sum_skeleton_facet_neighbors($top, $grid);
# Master: 59.683 ms (0 allocations: 0 bytes)
#     PR: 21.887 ms (0 allocations: 0 bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant