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

Speedup 2:1 pools, and separate pow benchmarks to a separate file #62

Merged
merged 5 commits into from
Apr 6, 2021

Conversation

ValarDragon
Copy link
Member

@ValarDragon ValarDragon commented Apr 2, 2021

A 2:1 pool has a weight ratio of .333333... / .666666... = 1/2 used in certain operations. This change adds a fast route for such operations. Furthermore it splits up the benchmarks into its own file, and changes the numeric inputs to be in a string format for easier debugging later.

Before:

BenchmarkSqrtPow-16    	   19940	     60491 ns/op	   33544 B/op	    1155 allocs/op

After:

BenchmarkSqrtPow-16    	   74811	     14814 ns/op	    7672 B/op	     321 allocs/op

This is a 4.1x speedup for this case. We should later add an approxEqual function, and use that here instead of exact equals.

@ValarDragon ValarDragon requested a review from Thunnini April 2, 2021 00:53
@ValarDragon
Copy link
Member Author

In the last commit, I've also removed allocating constants for constants that wouldn't get a speedup from #56 's idea of implementing in-place decimal ops.

Furthermore, I renamed subSign to absDifferenceWithSign, to reflect that its returning |a - b|, (a - b).sign(). (From the function name, I thought it was a - b, (a-b).sign()

@ValarDragon ValarDragon mentioned this pull request Apr 5, 2021
@ValarDragon ValarDragon merged commit bd0dd19 into main Apr 6, 2021
@ValarDragon ValarDragon deleted the refactor_pow branch April 6, 2021 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants