Skip to content

Conversation

@Conengmo
Copy link
Member

@ConengmoConengmo commented Mar 15, 2025

Addresses #174.

Our tests are very slow because of the linear_gradient function. Speed it up without incorporating a new dependency like Numpy.

How do we know this new implementation is correct? I made tests that pass on the old version and also on the new version. That should give confidence the output of both versions is exactly the same.

Performance:

import timeit from branca.utilities import linear_gradient %timeit linear_gradient(["#FF0000", "#00FF00", "#0000FF"], 10) 

Old version:
1.82 ms ± 18.8 μs per loop (mean ± std. dev. of 7 runs, 1,000 loops each)

New version:
7.46 μs ± 39.6 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

That's roughly 250 times faster. The tests now run in seconds, which was 4 to 7 minutes before.

@ConengmoConengmoforce-pushed the faster-linear-gradient branch 2 times, most recently from 5044843 to b29ecb6CompareMarch 15, 2025 17:33
@ConengmoConengmo marked this pull request as ready for review March 15, 2025 21:20
@ConengmoConengmo changed the title Faster linear_gradient [wip]Faster linear_gradient Mar 15, 2025
@ConengmoConengmo linked an issue Mar 15, 2025 that may be closed by this pull request
@ConengmoConengmoforce-pushed the faster-linear-gradient branch from 875263a to a73f1ccCompareMarch 18, 2025 08:57
@ConengmoConengmo changed the title Faster linear_gradient Faster linear_gradient to improve test speedMar 18, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_color_brewer_extendability is very very slow

1 participant

@Conengmo