Changeset 402 for trunk/src/core/time.cc
- Timestamp:
- 06/13/15 21:51:27 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/time.cc
r401 r402 85 85 nv::uint32 nv::get_cpu_ms() 86 86 { 87 return (uint32)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000.0) ) ;87 return static_cast<uint32>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000.0f ) ) ; 88 88 } 89 89 90 90 nv::uint64 nv::get_cpu_us() 91 91 { 92 return (uint64)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000000.0) ) ;92 return static_cast<uint64>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000000.0f ) ) ; 93 93 } 94 94 … … 99 99 QueryPerformanceCounter(&now); 100 100 LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart; 101 return (uint32) (1000.0 * result / (double) zero_timer.frequency.QuadPart);101 return static_cast<uint32>(1000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) ); 102 102 #else 103 103 struct timeval now; 104 104 gettimeofday(&now, NULL); 105 return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 );105 return static_cast<uint32>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 ); 106 106 #endif 107 107 } … … 113 113 QueryPerformanceCounter(&now); 114 114 LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart; 115 return (uint64) (1000000.0 * result / (double) zero_timer.frequency.QuadPart);115 return static_cast<uint64>(1000000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) ); 116 116 #else 117 117 struct timeval now; 118 118 gettimeofday(&now, NULL); 119 return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) );119 return static_cast<uint64>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) ); 120 120 #endif 121 121 }
Note: See TracChangeset
for help on using the changeset viewer.