Skip to content

int-to-string conversions significantly slower in libc++ compared to MSVC STL #40476

@tanderson-google

Description

@tanderson-google
Bugzilla Link 41131
Resolution FIXED
Resolved on Mar 19, 2019 13:35
Version unspecified
OS Windows NT
CC @mclow

Extended Description

On my win10 machine, the below program runs in 2.647s with libc++ and 0.357s with MSVC's STL. Most of the time is spent converting int to string:

snprintf_l() src/support/win32/locale_win32.cpp
std::num_put<>::do_put() include/locale:1461
std::num_put<>::put() include/locale:1279
std::basic_ostream<>::operator<<() include/ostream:462
main() main.cc:6

The problem appears to be that snprintf_l() makes 10 calls to setlocale() via __libcpp_locale_guard.


#include
int main() {
int x = 1234;
std::ostringstream os;
for (int i = 0; i < 100000; i++) {
os << x;
os.clear();
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions