-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Integer to_string is slow #135543
Copy link
Copy link
Closed
Labels
A-fmtArea: `core::fmt`Area: `core::fmt`C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing such
Metadata
Metadata
Assignees
Labels
A-fmtArea: `core::fmt`Area: `core::fmt`C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing such
Type
Fields
Give feedbackNo fields configured for issues without a type.
On my machine, the following code runs in 3 seconds in stable version, release build:
whereas the C++ counterpart runs in 1.2 seconds with
-O2:I've found that most of the time loss comes from passing
&strthrough a formatter instead of directlymemcpying; replacingto_stringwith _fmt with.to_owned()at the end speeds it up to around 1.6s.