demos/spectrum/3rdparty/fftreal/stopwatch/ClockCycleCounter.h
changeset 25 e24348a560a6
equal deleted inserted replaced
23:89e065397ea6 25:e24348a560a6
       
     1 /*****************************************************************************
       
     2 
       
     3         ClockCycleCounter.h
       
     4         Copyright (c) 2003 Laurent de Soras
       
     5 
       
     6 Instrumentation class, for accurate time interval measurement. You may have
       
     7 to modify the implementation to adapt it to your system and/or compiler.
       
     8 
       
     9 --- Legal stuff ---
       
    10 
       
    11 This library is free software; you can redistribute it and/or
       
    12 modify it under the terms of the GNU Lesser General Public
       
    13 License as published by the Free Software Foundation; either
       
    14 version 2.1 of the License, or (at your option) any later version.
       
    15 
       
    16 This library is distributed in the hope that it will be useful,
       
    17 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    19 Lesser General Public License for more details.
       
    20 
       
    21 You should have received a copy of the GNU Lesser General Public
       
    22 License along with this library; if not, write to the Free Software
       
    23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    24 
       
    25 *Tab=3***********************************************************************/
       
    26 
       
    27 
       
    28 
       
    29 #if ! defined (stopwatch_ClockCycleCounter_HEADER_INCLUDED)
       
    30 #define	stopwatch_ClockCycleCounter_HEADER_INCLUDED
       
    31 
       
    32 #if defined (_MSC_VER)
       
    33 	#pragma once
       
    34 	#pragma warning (4 : 4250) // "Inherits via dominance."
       
    35 #endif
       
    36 
       
    37 
       
    38 
       
    39 /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
       
    40 
       
    41 #include	"def.h"
       
    42 #include	"Int64.h"
       
    43 
       
    44 
       
    45 
       
    46 namespace stopwatch
       
    47 {
       
    48 
       
    49 
       
    50 
       
    51 class ClockCycleCounter
       
    52 {
       
    53 
       
    54 /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
       
    55 
       
    56 public:
       
    57 
       
    58 						ClockCycleCounter ();
       
    59 
       
    60 	stopwatch_FORCEINLINE void
       
    61 						start ();
       
    62 	stopwatch_FORCEINLINE void
       
    63 						stop_lap ();
       
    64 	Int64				get_time_total () const;
       
    65 	Int64				get_time_best_lap () const;
       
    66 
       
    67 
       
    68 
       
    69 /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
       
    70 
       
    71 protected:
       
    72 
       
    73 
       
    74 
       
    75 /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
       
    76 
       
    77 private:
       
    78 
       
    79 	void				compute_clk_mul ();
       
    80 	void				compute_measure_time_total ();
       
    81 	void				compute_measure_time_lap ();
       
    82 
       
    83 	static void		spend_time ();
       
    84 	static stopwatch_FORCEINLINE Int64
       
    85 						read_clock_counter ();
       
    86 
       
    87 	Int64				_start_time;
       
    88 	Int64				_state;
       
    89 	Int64				_best_score;
       
    90 
       
    91 	static Int64	_measure_time_total;
       
    92 	static Int64	_measure_time_lap;
       
    93 	static int		_clk_mul;
       
    94 	static bool		_init_flag;
       
    95 
       
    96 
       
    97 
       
    98 /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
       
    99 
       
   100 private:
       
   101 
       
   102 						ClockCycleCounter (const ClockCycleCounter &other);
       
   103 	ClockCycleCounter &
       
   104 						operator = (const ClockCycleCounter &other);
       
   105 	bool				operator == (const ClockCycleCounter &other);
       
   106 	bool				operator != (const ClockCycleCounter &other);
       
   107 
       
   108 };	// class ClockCycleCounter
       
   109 
       
   110 
       
   111 
       
   112 }	// namespace stopwatch
       
   113 
       
   114 
       
   115 
       
   116 #include	"ClockCycleCounter.hpp"
       
   117 
       
   118 
       
   119 
       
   120 #endif	// stopwatch_ClockCycleCounter_HEADER_INCLUDED
       
   121 
       
   122 
       
   123 
       
   124 /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/