update benchmark on wl_ball

This commit is contained in:
Marek Kaluba 2023-03-22 21:44:33 +01:00
parent c69eff1540
commit 038fc29b81
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
1 changed files with 17 additions and 23 deletions

View File

@ -5,14 +5,18 @@ using Groups
function wl_ball(F; radius::Integer) function wl_ball(F; radius::Integer)
g, state = iterate(F) g, state = iterate(F)
while length(word(g)) <= radius sizes = Int[]
while length(sizes) radius
res = iterate(F, state) res = iterate(F, state)
isnothing(res) && break isnothing(res) && break
g, state = res g, state = res
if length(word(g)) > length(sizes)
push!(sizes, length(state.seen) - 1)
end
end end
elts = collect(state.seen) elts = collect(state.seen)
elts = resize!(elts, length(elts)-1) resize!(elts, sizes[end] - 1)
return elts return elts, sizes[2:end]
end end
@testset "Benchmarks" begin @testset "Benchmarks" begin
@ -25,21 +29,16 @@ end
let G = FN let G = FN
S = unique([gens(G); inv.(gens(G))]) S = unique([gens(G); inv.(gens(G))])
sizes1 = last(Groups.wlmetric_ball(S, radius=R, threading=false)) sizes1 = last(Groups.wlmetric_ball(S; radius = R))
sizes2 = last(Groups.wlmetric_ball(S, radius=R, threading=true)) sizes2 = last(wl_ball(G; radius = R))
l = length(wl_ball(G, radius=R))
@test sizes1 == sizes2 @test sizes1 == sizes2
@test last(sizes1) == l
@info "Ball of radius $R in $(parent(first(S)))" sizes=sizes1 @info "Ball of radius $R in $(parent(first(S)))" sizes = sizes1
@info "serial" @info "serial"
@time Groups.wlmetric_ball(S, radius=R, threading=false) @time Groups.wlmetric_ball(S, radius = R)
@info "threaded"
@time Groups.wlmetric_ball(S, radius=R, threading=true)
@info "iteration" @info "iteration"
@time wl_ball(G, radius=R) @time wl_ball(G, radius = R)
end end
end end
@ -51,21 +50,16 @@ end
let G = SAutFN let G = SAutFN
S = unique([gens(G); inv.(gens(G))]) S = unique([gens(G); inv.(gens(G))])
sizes1 = last(Groups.wlmetric_ball(S, radius=R, threading=false)) sizes1 = last(Groups.wlmetric_ball(S; radius = R))
sizes2 = last(Groups.wlmetric_ball(S, radius=R, threading=true)) sizes2 = last(wl_ball(G; radius = R))
l = length(wl_ball(G, radius=R))
@test sizes1 == sizes2 @test sizes1 == sizes2
@test last(sizes1) == l
@info "Ball of radius $R in $(parent(first(S)))" sizes=sizes1 @info "Ball of radius $R in $(parent(first(S)))" sizes = sizes1
@info "serial" @info "serial"
@time Groups.wlmetric_ball(S, radius=R, threading=false) @time Groups.wlmetric_ball(S, radius = R)
@info "threaded"
@time Groups.wlmetric_ball(S, radius=R, threading=true)
@info "iteration" @info "iteration"
@time wl_ball(G, radius=R) @time wl_ball(G, radius = R)
end end
end end
end end