File: perftimer.h

package info (click to toggle)
r-cran-pcapp 1.9-73-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 800 kB
  • sloc: cpp: 5,961; ansic: 917; sh: 13; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 460 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "time.h"	//	2do: move this file to a util directory!

	class CPerfTimer
	{
	public:

		CPerfTimer () : m_start (clock ()) {}

		void Restart () { m_start  = clock () ; }

		int GetTimeMS ()
		{
			return FormatTimeMS (clock ()) ;
		}	

		int FormatTimeMS (clock_t end)
		{
			end -= m_start ;

			if (CLOCKS_PER_SEC != 1000)
				end = (clock_t) ((end  * 1000.0 / CLOCKS_PER_SEC)) ;

			return int (end) ;
			
		}

	protected:
		clock_t m_start ;
	} ;