
#ifndef _StopWatch_H_
#define _StopWatch_H_


#include "basic_common.h"

#ifdef WIN32
#	include <windows.h>
#else 
#	include <sys/time.h>
#endif // WIN32

/**
* 
* The purpose of this file is to make a timer function
* that is as precise as possible on any given platform.
*
* SystemStopWatch prints to cerr the elapsed time between 
* the line where it is declared (or restart) and the end
* of the scope where it is declared.
*
* usage example:
*   {
*      StopWatch clock ;
*      do_something() ;
*      std::cout << "Time: " << clock.elapsed() << std::endl;
*   } 
*/



class BASIC_API StopWatch 
{
public :
	StopWatch() ;
	~StopWatch() ;

	// returns user elapsed time since the construction (or restart)(in seconds).
	double elapsed() const ;

	void   start() ;

private:

#ifdef WIN32
	LONGLONG  freq_;
	LONGLONG  start_count_;
#else
	timeval start_time_;
#endif

} ;


#endif

