// This is a high resolution timer, accurate to the microsecond.
// To use, you can start() your timer, then output the return
//     of the end() function.
// Will work with Linux and Solaris.

#ifndef _TIMER_H_
#define _TIMER_H_

#include <stdio.h>
#include <sys/time.h>

class Timer
	{
	public:

	// Constructor
	Timer()
		{
		}
	
	// Destructors
	~Timer()
		{
		}

	struct timeval _start, _end;

	// Starts Internal Timer
	void start()
		{
		gettimeofday(&_start, NULL);
		}

	// Ends Internal Timer And Returns
	// Total Time Recorded
	long end()
		{
		gettimeofday(&_end, NULL);
		long lapsed;
		lapsed =((_end.tv_sec - _start.tv_sec)* 1000000) + 
			(_end.tv_usec - _start.tv_usec);
		return lapsed;
		}

	};

#endif

// Timer Implemented By Vivek Gupta - http://www.lilviv.com
