loop_time_test current work-in-progress

This commit is contained in:
Beman
2013-05-27 08:53:18 -04:00
parent 32b04869e8
commit 50b5488997
4 changed files with 104 additions and 11 deletions

View File

@@ -6,13 +6,15 @@
project
: source-location ../test : requirements
# <library>/boost/timer//boost_timer
# <toolset>msvc:<asynch-exceptions>on
<toolset>msvc:<asynch-exceptions>on
;
SOURCES = speed_test speed_test_functions ;
exe "speed_test"
: $(SOURCES).cpp ../../timer/build//boost_timer
;
exe "loop_time_test"
: loop_time_test.cpp ../../timer/build//boost_timer
;

View File

@@ -183,6 +183,96 @@ application concerns.</p>
</tr>
</table>
<h2><a name="Performance">Performance</a></h2>
<p>Consider this problem:</p>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td colspan="2"><b><i>Add 100 to a big endian value in a file, then write the
result to a file</i> </b> </td>
</tr>
<tr>
<td><i><b>Endian type approach</b></i></td>
<td><i><b>Endian conversion approach</b></i></td>
</tr>
<tr>
<td valign="top">
<pre>
big_int32_t x;
... read into x from a file ...
x += 100;
... write x to a file ...
</pre>
</td>
<td>
<pre>
int32_t x;
... read into x from a file ...
big_endian(x);
x += 100;
big_endian(x);
... write x to a file ...
</pre>
</td>
</tr>
</table>
<p>There will be no performance difference between the two approaches. Optimizing compilers will likely
generate exactly the same code for both.</p>
<p>Now consider a slightly different problem:&nbsp; </p>
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td colspan="2">Add a million values to a big endian value in a file, then write the
result to a file </td>
</tr>
<tr>
<td><i><b>Endian type approach</b></i></td>
<td><i><b>Endian conversion approach</b></i></td>
</tr>
<tr>
<td valign="top">
<pre>
big_int32_t x;
... read into x from a file ...
for (int32_t i = 0; i &lt; 1000000; ++i)
x += f(i);
... write x to a file ...
</pre>
</td>
<td>
<pre>
int32_t x;
... read into x from a file ...
big_endian(x);
for (int32_t i = 0; i &lt; 1000000; ++i)
x += f(i);
big_endian(x);
... write x to a file ...
</pre>
</td>
</tr>
</table>
<p>There will be no performance difference. Optimizing compilers will likely
generate exactly the same code for both approaches.&nbsp; </p>
<h2>Timing tests</h2>
<p>These tests were run against release builds on a circa 2012 4-core little endian X64 Intel Core i5-3570K
CPU @ 3.40GHz under Windows 7.</p>
@@ -355,7 +445,7 @@ Tim Blechmann, Tim Moore, tymofey, Tomas Puverle, Vincente Botet, Yuval Ronen
and Vitaly Budovski,.</p>
<hr>
<p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25 May, 2013<!--webbot bot="Timestamp" endspan i-checksum="13986" --></p>
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->26 May, 2013<!--webbot bot="Timestamp" endspan i-checksum="13988" --></p>
<p><EFBFBD> Copyright Beman Dawes, 2011, 2013</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>

View File

@@ -15,6 +15,7 @@
#include <boost/detail/scoped_enum_emulation.hpp>
#include <boost/static_assert.hpp>
#include <algorithm>
#include <cstring> // for memcpy
//------------------------------------- synopsis ---------------------------------------//

View File

@@ -140,12 +140,12 @@ namespace
cout << "</tr>\n";
}
void test_little_int32()
{
cout << "<tr><td>32-bit aligned little endian</td>";
time<int32_t, little_int32_t>();
cout << "</tr>\n";
}
//void test_little_int32()
//{
// cout << "<tr><td>32-bit aligned little endian</td>";
// time<int32_t, little_int32_t>();
// cout << "</tr>\n";
//}
//void test_big_int64()
//{
@@ -196,7 +196,7 @@ int cpp_main(int argc, char* argv[])
//test_big_int16();
//test_little_int16();
test_big_int32();
test_little_int32();
//test_little_int32();
//test_big_int64();
//test_little_int64();