Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>-O3 Dual core Macbook pro 2.4ghz</p> <blockquote> <p>std::max(x1, x2) Time: 4.19488 RMAAx's : 4.19613 if Time: 4.18775 ? Time: 4.18831 </p> <p>std::max(x1, x2) Time: 4.1836 RMAAx's : 4.18274 if Time: 4.18603 ? Time: 4.18857 </p> <p>std::max(x1, x2) Time: 4.18714 RMAAx's : 4.18759 if Time: 4.19752 ? Time: 4.19797 </p> <p>std::max(x1, x2) Time: 4.1926 RMAAx's : 4.19293 if Time: 4.19334 ? Time: 4.19626 </p> <p>std::max(x1, x2) Time: 4.18963 RMAAx's : 4.19628 if Time: 4.19253 ? Time: 4.19107</p> </blockquote> <pre><code>#include &lt;iostream&gt; using namespace std; int main (int argc, char * const argv[]) { uint64_t iterations = 10000000000; float x1 = 3455.232; float x2 = 7456.856; float y = 0; for (int count = 0; count &lt; 5; ++count) { clock_t begin_time = clock(); for (uint64_t ii = 0; ii &lt; iterations; ++ii) { y = std::max(x1, x2); } std::cout &lt;&lt; "std::max(x1, x2) Time: " &lt;&lt; float( clock () - begin_time ) / CLOCKS_PER_SEC &lt;&lt; endl; begin_time = clock(); for (uint64_t ii = 0; ii &lt; iterations; ++ii) { y = x1; if (y &lt; x2) y = x2; } std::cout &lt;&lt; "RMAAx's : " &lt;&lt; float( clock () - begin_time ) / CLOCKS_PER_SEC &lt;&lt; endl; begin_time = clock(); for (uint64_t ii = 0; ii &lt; iterations; ++ii) { if (x1 &gt; x2) y = x1; else y = x2; } std::cout &lt;&lt; "if Time: " &lt;&lt; float( clock () - begin_time ) / CLOCKS_PER_SEC &lt;&lt; endl; begin_time = clock(); for (uint64_t ii = 0; ii &lt; iterations; ++ii) { y = x1 &gt; x2 ? x1 : x2; } std::cout &lt;&lt; "? Time: " &lt;&lt; float( clock () - begin_time ) / CLOCKS_PER_SEC &lt;&lt; endl; } return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload