00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if defined(_MSC_VER)
00025 #pragma once
00026 #endif
00027
00028 #ifndef PBRT_CORE_TIMER_H
00029 #define PBRT_CORE_TIMER_H
00030
00031
00032 #include "pbrt.h"
00033 #if defined (PBRT_IS_WINDOWS)
00034 #include <windows.h>
00035 #if (_MSC_VER >= 1400)
00036 #include <stdio.h>
00037 #define snprintf _snprintf
00038 #endif
00039 #else
00040 #include <sys/time.h>
00041 #endif
00042
00043
00044 class Timer {
00045 public:
00046
00047 Timer();
00048
00049 void Start();
00050 void Stop();
00051 void Reset();
00052
00053 double Time();
00054 private:
00055
00056 double time0, elapsed;
00057 bool running;
00058 double GetTime();
00059 #if defined(PBRT_IS_WINDOWS)
00060
00061 LARGE_INTEGER performance_counter, performance_frequency;
00062 double one_over_frequency;
00063 #else
00064
00065 struct timeval timeofday;
00066 #endif
00067 };
00068
00069
00070
00071 #endif // PBRT_CORE_TIMER_H