Subversion Repositories gelsvn

Rev

Rev 39 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 39 Rev 102
Line 2... Line 2...
2
#define __OSTIMER_H__
2
#define __OSTIMER_H__
3
 
3
 
4
// Created by bdl 5. april 2002
4
// Created by bdl 5. april 2002
5
// The purpose of this file is to make a timer function that is as 
5
// The purpose of this file is to make a timer function that is as 
6
// precise as posible on any given platform
6
// precise as posible on any given platform
-
 
7
#if (_MSC_VER >= 1200)
-
 
8
#pragma warning (disable: 4244)
7
 
9
#endif
8
#ifdef WIN32
10
#ifdef WIN32
9
#include <windows.h>
11
#include <windows.h>
10
static LARGE_INTEGER	largeInteger;
12
static LARGE_INTEGER	largeInteger;
11
#else
13
#else
12
#include <sys/time.h>
14
#include <sys/time.h>
Line 34... Line 36...
34
 
36
 
35
		float get_secs() {
37
		float get_secs() {
36
#ifdef WIN32
38
#ifdef WIN32
37
			QueryPerformanceCounter(&largeInteger);
39
			QueryPerformanceCounter(&largeInteger);
38
			double now_count = largeInteger.QuadPart;
40
			double now_count = largeInteger.QuadPart;
39
			return (float)(now_count-start_count)/freq;
41
			return (float)((now_count-start_count)/freq);
40
#else
42
#else
41
			timeval now;
43
			timeval now;
42
			gettimeofday(&now,0);
44
			gettimeofday(&now,0);
43
			return (now.tv_sec-start_time.tv_sec) + 
45
			return (now.tv_sec-start_time.tv_sec) + 
44
				(now.tv_usec-start_time.tv_usec)/1.0e6;
46
				(now.tv_usec-start_time.tv_usec)/1.0e6;