From 50b548899715fbb2757eacc54c5df9443cfa685b Mon Sep 17 00:00:00 2001 From: Beman Date: Mon, 27 May 2013 08:53:18 -0400 Subject: [PATCH] loop_time_test current work-in-progress --- build/Jamfile.v2 | 8 ++- doc/index.html | 92 ++++++++++++++++++++++++++++- include/boost/endian/conversion.hpp | 1 + test/loop_time_test.cpp | 14 ++--- 4 files changed, 104 insertions(+), 11 deletions(-) diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index fe80c78..4bf7726 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -6,13 +6,15 @@ project : source-location ../test : requirements -# /boost/timer//boost_timer -# msvc:on + msvc: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 + ; diff --git a/doc/index.html b/doc/index.html index dab871f..00eb839 100644 --- a/doc/index.html +++ b/doc/index.html @@ -183,6 +183,96 @@ application concerns.

+

Performance

+ +

Consider this problem:

+ + + + + + + + + + + + + +
Add 100 to a big endian value in a file, then write the + result to a file
Endian type approachEndian conversion approach
+
+big_int32_t x;
+
+... read into x from a file ...
+
+x += 100;
+
+... write x to a file ...
+
+
+
  
+int32_t x;
+
+... read into x from a file ...
+
+big_endian(x);
+x += 100;
+big_endian(x);
+
+... write x to a file ...
+
+
+ +

There will be no performance difference between the two approaches. Optimizing compilers will likely +generate exactly the same code for both.

+ +

Now consider a slightly different problem: 

+ + + + + + + + + + + + + +
Add a million values to a big endian value in a file, then write the + result to a file
Endian type approachEndian conversion approach
+
+big_int32_t x;
+
+... read into x from a file ...
+
+for (int32_t i = 0; i < 1000000; ++i)
+  x += f(i);
+
+... write x to a file ...
+
+
+
+int32_t x;
+
+... read into x from a file ...
+
+big_endian(x);
+
+for (int32_t i = 0; i < 1000000; ++i)
+  x += f(i);
+
+big_endian(x);
+
+... write x to a file ...
+
+
+ +

There will be no performance difference. Optimizing compilers will likely +generate exactly the same code for both approaches. 

+

Timing tests

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.

@@ -355,7 +445,7 @@ Tim Blechmann, Tim Moore, tymofey, Tomas Puverle, Vincente Botet, Yuval Ronen and Vitaly Budovski,.


Last revised: -25 May, 2013

+26 May, 2013

© Copyright Beman Dawes, 2011, 2013

Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt

diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index cb65ccc..6353ea4 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -15,6 +15,7 @@ #include #include #include +#include // for memcpy //------------------------------------- synopsis ---------------------------------------// diff --git a/test/loop_time_test.cpp b/test/loop_time_test.cpp index 72783f1..a38db3f 100644 --- a/test/loop_time_test.cpp +++ b/test/loop_time_test.cpp @@ -140,12 +140,12 @@ namespace cout << "\n"; } - void test_little_int32() - { - cout << "32-bit aligned little endian"; - time(); - cout << "\n"; - } + //void test_little_int32() + //{ + // cout << "32-bit aligned little endian"; + // time(); + // cout << "\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();