| 57 | |
| 58 | |
| 59 | float Timer::MicroSeconds() { |
| 60 | if (!has_run_at_least_once()) { |
| 61 | LOG(WARNING) << "Timer has never been run before reading time."; |
| 62 | return 0; |
| 63 | } |
| 64 | if (running()) { |
| 65 | Stop(); |
| 66 | } |
| 67 | if (Caffe::mode() == Caffe::GPU) { |
| 68 | #ifndef CPU_ONLY |
| 69 | CUDA_CHECK(cudaEventElapsedTime(&elapsed_milliseconds_, start_gpu_, |
| 70 | stop_gpu_)); |
| 71 | // Cuda only measure milliseconds |
| 72 | elapsed_microseconds_ = elapsed_milliseconds_ * 1000; |
| 73 | #else |
| 74 | NO_GPU; |
| 75 | #endif |
| 76 | } else { |
| 77 | elapsed_microseconds_ = (stop_cpu_ - start_cpu_).total_microseconds(); |
| 78 | } |
| 79 | return elapsed_microseconds_; |
| 80 | } |
| 81 | |
| 82 | float Timer::MilliSeconds() { |
| 83 | if (!has_run_at_least_once()) { |
no outgoing calls
no test coverage detected