Skip to content

Improve performance for rightOfBack and leftOfBack#51

Open
jfmengels wants to merge 2 commits intoelm-community:masterfrom
jfmengels:righofback-perf
Open

Improve performance for rightOfBack and leftOfBack#51
jfmengels wants to merge 2 commits intoelm-community:masterfrom
jfmengels:righofback-perf

Conversation

@jfmengels
Copy link

I had a quick look at whether there were functions with "obvious" performance improvements, and came across rightOfBack (the List.reverse + List.head called out to me).

I tried several approaches (that you can go through in this benchmark). The final benchmark gives the following:
Screenshot from 2021-11-10 17-26-12

leftOfBack had a very similar algorithm, so I updated it as well to use the same improvements, with the following results (benchmark)

Screenshot from 2021-11-10 17-19-02

Less impressive, but still a nice improvement.

There were no tests for these 2 functions, so I added basic ones, based on the examples.

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

Successfully merging this pull request may close these issues.

1 participant

Comments