<p>Results on my system with gcc:</p>

<pre><code>$ ./main2
SortStruct results:
unnecessaryCodeRemovalPreventer = 1.09092e+08
sort duration = 21890ms
std::pair results:
unnecessaryCodeRemovalPreventer = 1.20977e+08
sort duration = 18936ms
</code></pre>

<p>and with clang:</p>

<pre><code>SortStruct results:
unnecessaryCodeRemovalPreventer = 1.0909e+08
sort duration = 81754ms
std::pair results:
unnecessaryCodeRemovalPreventer = 1.01206e+08
sort duration = 80806ms
</code></pre>

<p>clang is much slower!  I also had one more test I wanted to do---using the default comparator for <code>std::pair</code>.  So I removed the third argument from line 74 of main2.cpp and switched the order of the pair to hold double first then size_t.</p>

<p>gcc:</p>

<pre><code>SortStruct results:
unnecessaryCodeRemovalPreventer = 1.09092e+08
sort duration = 21970ms
std::pair results:
unnecessaryCodeRemovalPreventer = 1.26484e+08
sort duration = 19171ms
</code></pre>

<p>clang:</p>

<pre><code>
</code></pre>

<p>SortStruct results:<br>
unnecessaryCodeRemovalPreventer = 1.09091e+08<br>
sort duration = 80945ms<br>
std::pair results:<br>
unnecessaryCodeRemovalPreventer = 1.14581e+08<br>
sort duration = 82204ms</p>

<pre><code>
So I guess the best solution is to use `std::pair`, but with the lambda, as you have it written.
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/issues/712#issuecomment-229732827">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFDBMxJzp3wmGhJVJ1u36g3l1JSGiks5qQ_7qgaJpZM4JBmsJ">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFJP4oB11KEDtcoURqYb--5S6X0xyks5qQ_7qgaJpZM4JBmsJ.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/issues/712#issuecomment-229732827"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>