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

Memoize expensive polynomial searches #295

Closed
mhostetter opened this issue Mar 18, 2022 · 0 comments
Closed

Memoize expensive polynomial searches #295

mhostetter opened this issue Mar 18, 2022 · 0 comments
Labels
performance Affects speed/performance

Comments

@mhostetter
Copy link
Owner

mhostetter commented Mar 18, 2022

Use LRU cache to speed up subsequent calls to galois.irreducible_poly() and galois.primtiive_poly().

Before

In [2]: %time galois.primitive_poly(7, 4)
CPU times: user 677 ms, sys: 13.2 ms, total: 691 ms
Wall time: 745 ms
Out[2]: Poly(x^4 + x^2 + 3x + 5, GF(7))

In [3]: %time galois.primitive_poly(7, 4)
CPU times: user 338 ms, sys: 10.6 ms, total: 348 ms
Wall time: 337 ms
Out[3]: Poly(x^4 + x^2 + 3x + 5, GF(7))

In [4]: %time galois.primitive_poly(7, 4)
CPU times: user 331 ms, sys: 17 ms, total: 348 ms
Wall time: 336 ms
Out[4]: Poly(x^4 + x^2 + 3x + 5, GF(7))

In [5]: %time galois.primitive_poly(7, 4)
CPU times: user 355 ms, sys: 12.8 ms, total: 368 ms
Wall time: 348 ms
Out[5]: Poly(x^4 + x^2 + 3x + 5, GF(7))

After

In [1]: import galois

In [2]: %time galois.primitive_poly(7, 4)
CPU times: user 691 ms, sys: 12.7 ms, total: 703 ms
Wall time: 756 ms
Out[2]: Poly(x^4 + x^2 + 3x + 5, GF(7))

In [3]: %time galois.primitive_poly(7, 4)
CPU times: user 20 µs, sys: 13 µs, total: 33 µs
Wall time: 35 µs
Out[3]: Poly(x^4 + x^2 + 3x + 5, GF(7))

In [4]: %time galois.primitive_poly(7, 4)
CPU times: user 20 µs, sys: 13 µs, total: 33 µs
Wall time: 34.8 µs
Out[4]: Poly(x^4 + x^2 + 3x + 5, GF(7))

In [5]: %time galois.primitive_poly(7, 4)
CPU times: user 33 µs, sys: 0 ns, total: 33 µs
Wall time: 34.6 µs
Out[5]: Poly(x^4 + x^2 + 3x + 5, GF(7))
@mhostetter mhostetter added the performance Affects speed/performance label Mar 18, 2022
@mhostetter mhostetter changed the title Memoize slow polynomial functions Memoize expensive polynomial searches Mar 18, 2022
mhostetter added a commit that referenced this issue Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Affects speed/performance
Projects
None yet
Development

No branches or pull requests

1 participant