1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-04 02:50:28 +01:00
Groups.jl/test/benchmarks.jl

66 lines
1.6 KiB
Julia
Raw Normal View History

using BenchmarkTools
using Test
using Groups
function wl_ball(F; radius::Integer)
g, state = iterate(F)
2023-03-22 21:44:33 +01:00
sizes = Int[]
while length(sizes) radius
res = iterate(F, state)
isnothing(res) && break
g, state = res
2023-03-22 21:44:33 +01:00
if length(word(g)) > length(sizes)
push!(sizes, length(state.seen) - 1)
end
end
elts = collect(state.seen)
2023-03-22 21:44:33 +01:00
resize!(elts, sizes[end] - 1)
return elts, sizes[2:end]
end
@testset "Benchmarks" begin
N = 4
@testset "iteration: FreeGroup" begin
FN = FreeGroup(N)
R = 8
let G = FN
S = unique([gens(G); inv.(gens(G))])
2023-03-22 21:44:33 +01:00
sizes1 = last(Groups.wlmetric_ball(S; radius = R))
sizes2 = last(wl_ball(G; radius = R))
@test sizes1 == sizes2
2023-03-22 21:44:33 +01:00
@info "Ball of radius $R in $(parent(first(S)))" sizes = sizes1
@info "serial"
2023-03-22 21:44:33 +01:00
@time Groups.wlmetric_ball(S, radius = R)
@info "iteration"
2023-03-22 21:44:33 +01:00
@time wl_ball(G, radius = R)
end
end
@testset "iteration: SAut(F_n)" begin
R = 4
FN = FreeGroup(N)
2022-04-02 15:53:55 +02:00
SAutFN = SpecialAutomorphismGroup(FN)
let G = SAutFN
S = unique([gens(G); inv.(gens(G))])
2023-03-22 21:44:33 +01:00
sizes1 = last(Groups.wlmetric_ball(S; radius = R))
sizes2 = last(wl_ball(G; radius = R))
@test sizes1 == sizes2
2023-03-22 21:44:33 +01:00
@info "Ball of radius $R in $(parent(first(S)))" sizes = sizes1
@info "serial"
2023-03-22 21:44:33 +01:00
@time Groups.wlmetric_ball(S, radius = R)
@info "iteration"
2023-03-22 21:44:33 +01:00
@time wl_ball(G, radius = R)
end
end
end