| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 #include "SysTimer_posix.h" | 7 #include "SysTimer_posix.h" |
| 8 | 8 |
| 9 static double interval_in_ms(timespec start_clock, timespec end_clock) | 9 static double interval_in_ms(timespec start_clock, timespec end_clock) |
| 10 { | 10 { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 double SysTimer::endWall() { | 44 double SysTimer::endWall() { |
| 45 timespec end_wall; | 45 timespec end_wall; |
| 46 if (-1 == clock_gettime(CLOCK_MONOTONIC, &end_wall)) { | 46 if (-1 == clock_gettime(CLOCK_MONOTONIC, &end_wall)) { |
| 47 timespec none = {0, 0}; | 47 timespec none = {0, 0}; |
| 48 end_wall = none; | 48 end_wall = none; |
| 49 } | 49 } |
| 50 return interval_in_ms(fWall, end_wall); | 50 return interval_in_ms(fWall, end_wall); |
| 51 } | 51 } |
| 52 |
| 53 static timespec init_launch_time() { |
| 54 timespec launchTime; |
| 55 if (-1 == clock_gettime(CLOCK_MONOTONIC, &launchTime)) { |
| 56 timespec none = {0, 0}; |
| 57 return none; |
| 58 } |
| 59 return launchTime; |
| 60 }; |
| 61 |
| 62 double GetTimeMs() { |
| 63 static const timespec launchTime = init_launch_time(); |
| 64 timespec now; |
| 65 if (-1 == clock_gettime(CLOCK_MONOTONIC, &now)) { |
| 66 return 0; |
| 67 } |
| 68 return interval_in_ms(launchTime, now); |
| 69 } |
| OLD | NEW |