Closed RexWzh closed 1 year ago
Also, it can be fixed by replacing the last two lines by
candidates = [xor.(matrix, mat) for mat in masks]
scores = penalty.(candidates)
mask = first(sort(1:8, by = i -> scores[i]))
matrix = candidates[mask]
And the test result will be much better: 9.184 ms (419671 allocations: 20.40 MiB)
However, I still don't know why it happened.
The new function
qrcode
is slower than the original one, as the following codes suggests.I split the function
qrcode
into two part to figure out why.First part:
Second part:
QRCoders.jl
559.462 μs (3144 allocations: 557.91 KiB)
QRCode.jl
676.829 μs (5491 allocations: 875.22 KiB)
QRCoders.jl
15.422 ms (728832 allocations: 34.75 MiB)
QRCode.jl
38.992 ms (1561712 allocations: 74.46 MiB)
However, if I combine the two parts, that is
QRCoders.jl
42.179 ms (1669104 allocations: 79.98 MiB)
QRCode.jl
38.375 ms (1567236 allocations: 75.32 MiB)
This seems really weird to me!
Glad to discuss with you if you are available ;) @johnnychen94