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

Decimal optimization #3

Closed
wants to merge 2 commits into from
Closed

Decimal optimization #3

wants to merge 2 commits into from

Conversation

homonoidian
Copy link
Collaborator

This particular implementation isn't 400x faster, nor 100x, nor even 10x, nor even 2x. It's about 20% faster, as small benchmarks and overall experimentation shows. E.g., looping a million times with old Decimal and new Decimal (in Crystal):

decimal old increment  13.20  ( 75.75ms) (± 5.93%)  61.0MB/op  54.68× slower
decimal new increment 721.82  (  1.39ms) (± 1.06%)    0.0B/op        fastest

But this is only a silly little benchmark. A simple loop 100000 times: [ ] in Novika now runs in about 17s instead of 20s, on my machine (Ryzen 3 2200g). The main thing is that we have 0 memory usage at most times now for numbers, while before even in simplest scenarios we had a small, but usage nevertheless.

This has almost no effect on the big picture, though. So for now, let this be is on hold, because it introduces complexity and possibility of bugs (the snake fix commit may be a bug in snake, or in the decimal implementation; the fact is that it has to do with random numbers, and there is no sure way to trigger it other than play snake for eternity).

Closes #1

- Small uses Int64
- Large uses BigInt
- Float uses BigFloat
@homonoidian homonoidian mentioned this pull request Aug 14, 2022
@homonoidian
Copy link
Collaborator Author

This is clearly an ancient PR! No way it's going to be merged anymore.

@homonoidian homonoidian closed this Jun 4, 2023
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.

Decimal optimization
1 participant