Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2008-06-30 05:02:29


Author: johnmaddock
Date: 2008-06-30 05:02:29 EDT (Mon, 30 Jun 2008)
New Revision: 46892
URL: http://svn.boost.org/trac/boost/changeset/46892

Log:
Added better Win32 control.
Text files modified:
   sandbox/math_toolkit/libs/math/performance/performance_measure.hpp | 13 ++++++++++++-
   1 files changed, 12 insertions(+), 1 deletions(-)

Modified: sandbox/math_toolkit/libs/math/performance/performance_measure.hpp
==============================================================================
--- sandbox/math_toolkit/libs/math/performance/performance_measure.hpp (original)
+++ sandbox/math_toolkit/libs/math/performance/performance_measure.hpp 2008-06-30 05:02:29 EDT (Mon, 30 Jun 2008)
@@ -10,11 +10,19 @@
 #include <boost/timer.hpp>
 #include <cstring>
 
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
 template <class F>
 double performance_measure(F f)
 {
    unsigned count = 1;
    double time, result;
+#ifdef _WIN32
+ int old_priority = GetThreadPriority(GetCurrentThread());
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+#endif
    //
    // Begin by figuring out how many times to repeat
    // the function call in order to get a measureable time:
@@ -37,7 +45,7 @@
    // result, generally speaking this gives us
    // consistent results:
    //
- for(unsigned i = 0; i < 10u;++i)
+ for(unsigned i = 0; i < 20u;++i)
    {
       boost::timer t;
       for(unsigned i = 0; i < count; ++i)
@@ -47,6 +55,9 @@
          result = time;
       t.restart();
    }
+#ifdef _WIN32
+ SetThreadPriority(GetCurrentThread(), old_priority);
+#endif
    return result / count;
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk