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

Improve Int#to_s(base: 10) performance (~10%) #9832

Merged

Conversation

makenowjust
Copy link
Contributor

Benchmark is here, and its result is:

     to_s  31.22k ( 32.03µs) (± 1.14%)  31.3kB/op   1.11× slower
fast_to_s  34.52k ( 28.97µs) (± 0.72%)  31.3kB/op        fastest

The basic idea comes from "Three Optimization Tips for C++".

Thank you.

Benchmark is [here](https://gist.github.com/MakeNowJust/2128ff45f232bea179d711b0788052ff),
and its result is:

```
     to_s  31.22k ( 32.03µs) (± 1.14%)  31.3kB/op   1.11× slower
fast_to_s  34.52k ( 28.97µs) (± 0.72%)  31.3kB/op        fastest
```

The basic idea comes from "[Three Optimization Tips for C++](https://www.slideshare.net/andreialexandrescu1/three-optimization-tips-for-c)".
@straight-shoota straight-shoota added this to the 1.0.0 milestone Nov 21, 2020
@straight-shoota straight-shoota merged commit d44a61f into crystal-lang:master Nov 23, 2020
@straight-shoota
Copy link
Member

Thanks @makenowjust

bcardiff pushed a commit to bcardiff/crystal that referenced this pull request Jan 25, 2021
bcardiff pushed a commit that referenced this pull request Jan 25, 2021
)

This reverts commit d44a61f.

Co-authored-by: TSUYUSATO Kitsune <make.just.on@gmail.com>
@makenowjust makenowjust deleted the int-to-s-performance branch February 12, 2021 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants