<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 - std::lower_bound speed can be improved."
href="https://bugs.llvm.org/show_bug.cgi?id=39129">39129</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>std::lower_bound speed can be improved.
</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>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</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>denis.yaroshevskij@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Recently Sean Parent discovered that his quickly hacked implementation of
lower_bound is faster than the one that comes with the libcxx:
<a href="https://twitter.com/SeanParent/status/1042925651898974210">https://twitter.com/SeanParent/status/1042925651898974210</a>
I did a quick experiment - the problem seems to be that he is using size_t
while std::lower_bound uses std::iterator_traits<I>::difference_type. size_t is
quicker to divide by two.
<a href="http://quick-bench.com/WhkonNgX40J3hk0A2Q8kQown96I">http://quick-bench.com/WhkonNgX40J3hk0A2Q8kQown96I</a>
I ran some more measurements - the patterns seems to stay the same - here is
binary search in 1000 integers, measured for looking up each number:
<a href="https://plot.ly/~dyaroshev/110/#/">https://plot.ly/~dyaroshev/110/#/</a></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>