Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:47

0001 //----------------------------------------------------------------------------
0002 /// @file time_measure.hpp
0003 /// @brief This class is done in order to simplify the time measure in the
0004 ///        benchmaark programs
0005 ///
0006 /// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n
0007 ///         Distributed under the Boost Software License, Version 1.0.\n
0008 ///         ( See accompanyingfile LICENSE_1_0.txt or copy at
0009 ///           http://www.boost.org/LICENSE_1_0.txt  )
0010 /// @version 0.1
0011 ///
0012 /// @remarks
0013 //-----------------------------------------------------------------------------
0014 #ifndef __BOOST_SORT_PARALLEL_TOOLS_TIME_MEASURE_HPP
0015 #define __BOOST_SORT_PARALLEL_TOOLS_TIME_MEASURE_HPP
0016 
0017 #include <ciso646>
0018 #include <chrono>
0019 
0020 namespace boost
0021 {
0022 namespace sort
0023 {
0024 namespace common
0025 {
0026 
0027 namespace chrn = std::chrono;
0028 //
0029 //***************************************************************************
0030 //                D E F I N I T I O N S
0031 //***************************************************************************
0032 typedef chrn::steady_clock::time_point           time_point;
0033 
0034 //
0035 //---------------------------------------------------------------------------
0036 //  function : now
0037 /// @brief return the time system in a internal format ( steady_clock)
0038 /// @return time in steady_clock format
0039 //---------------------------------------------------------------------------
0040 inline time_point now ( ) {   return chrn::steady_clock::now( ); };
0041 //
0042 //---------------------------------------------------------------------------
0043 //  function : subtract_time
0044 /// @brief return the time in double format
0045 /// @param [in] t1 : first  time in time_point format
0046 /// @param [in] t2 : second time in time_point format
0047 /// @return time in seconds of the difference of t1 - t2
0048 //---------------------------------------------------------------------------
0049 inline double subtract_time  ( const time_point & t1, const time_point & t2 )
0050 {   //------------------------ begin ---------------------------------
0051     chrn::duration<double> time_span =
0052                 chrn::duration_cast < chrn::duration < double > > ( t1 - t2 );
0053     return  time_span.count( );
0054 };
0055 
0056 //***************************************************************************
0057 };//    End namespace benchmark
0058 };//    End namespace sort
0059 };//    End namespace boost
0060 //***************************************************************************
0061 #endif