Repository navigation
Replies: 5 comments 2 replies
|
I asked an agent to benchmark Horner's method, substituting repeat calculations like
Full-year timings are medians of five runs, comparing the pre-Horner implementation with the current one. It also ran the full
The benchmark branch is here: https://github.com/mikofski/pvlib-python/blob/copilot/benchmark-test-spa/pvlib/spa.py |
|
As you said, as long as readability and reviewability of the code is kept, I'm in favor. For example, comment out the original lines or type the original equation similar to the reference, and explicitly state that the algorithm has been modified to speed it up. Bonus points for indicating the way it has been modified (e.g., applying Horner's method, simplified by exponential properties, etc.). Another piece that could use an improvement: pvlib-python/pvlib/atmosphere.py Lines 389 to 393 in 0c6ab77 |
|
According to the doc's Notes, https://numpy.org/doc/stable/reference/generated/numpy.polynomial.polynomial.polyval.html |
|
|
|
Hi @adriesse & @markcampanelli both were significantly slower (5x) when i tested |
Uh oh!
There was an error while loading. Please reload this page.
I mentioned it maybe previously, in general Horners is at least 10-15% faster than brute force polynomials with increasing powers because less more efficient operations. Maybe not useful in #2906, but might speed up spa heliocentric longitude:
pvlib-python/pvlib/spa.py
Lines 474 to 475 in 49530b4
rewritten as Horners:
only downside is that it's harder to compare with the original, which could be commented out with a note explaining Horners, and as long as tests pass, it should be okay
All reactions