You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use Custom Formatting for Integer Parts of Times (#577)
Going through the standard library's formatter is usually quite slow.
And usually we want to show either minutes or seconds that are in the
range from 0 to 59, or even tenths from 0 to 99. For those we can just
define a lookup table where we look up the formatted strings and
directly call `write_str` on the formatter instead of going through the
`write!` macro, which would go through a lot more setup. Additionally we
already have `itoa` as an indirect dependency which we now directly use
for formatting integers that are not bound that way. `itoa` generally
does the same algorithm as `std` but does so without going through any
formatting machinery and is thus a lot faster, but also much less
customizable.
Overall this and #576 together result in a `~3.86x` performance
improvement when formatting a time.
| When | Time |
|:------------|------------:|
| Both PRs | `59.205 ns` |
| Previous PR | `154.63 ns` |
| Before | `228.47 ns` |
0 commit comments