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

Contour perf: get rid of join(',') #1311

Closed
alexcjohnson opened this issue Jan 18, 2017 · 1 comment
Closed

Contour perf: get rid of join(',') #1311

alexcjohnson opened this issue Jan 18, 2017 · 1 comment

Comments

@alexcjohnson
Copy link
Collaborator

In our marching squares algorithm, we have a lot of statements that amount to indicesStr = indices.join(','). These make the code a little clearer (you can do a single === to find out if two locations are the same) but have a substantial perf cost:

timeit(function(v) { return v.join(',') === '2,2'; }, [2,3], 1000000)
0.00024889000000001397

timeit(function(v) { return v[0] === 2 && v[1] === 2; }, [2,3], 1000000)
0.000011064999999944121

Lets replace them with straight-up integer comparisons.

@rreusser
Copy link
Contributor

Like these? https://github.com/plotly/plotly.js/blob/master/src/traces/contour/find_all_paths.js#L89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants