<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - int-to-string conversions significantly slower in libc++ compared to MSVC STL"
href="https://bugs.llvm.org/show_bug.cgi?id=41131">41131</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>int-to-string conversions significantly slower in libc++ compared to MSVC STL
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>thomasanderson@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>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 <sstream>
int main() {
int x = 1234;
std::ostringstream os;
for (int i = 0; i < 100000; i++) {
os << x;
os.clear();
}
}
--------------------------------------------------------------------------------</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>