OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/base/timing.h" | |
12 #include "webrtc/base/timeutils.h" | |
13 | |
14 #if defined(WEBRTC_POSIX) | |
15 #include <errno.h> | |
16 #include <math.h> | |
17 #include <sys/time.h> | |
18 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | |
19 #include <mach/mach.h> | |
20 #include <mach/clock.h> | |
21 #endif | |
22 #elif defined(WEBRTC_WIN) | |
23 #include <sys/timeb.h> | |
24 #endif | |
25 | |
26 namespace rtc { | |
27 | |
28 Timing::Timing() {} | |
29 | |
30 Timing::~Timing() {} | |
31 | |
32 // static | |
33 double Timing::WallTimeNow() { | |
34 #if defined(WEBRTC_POSIX) | |
35 struct timeval time; | |
36 gettimeofday(&time, NULL); | |
37 // Convert from second (1.0) and microsecond (1e-6). | |
38 return (static_cast<double>(time.tv_sec) + | |
39 static_cast<double>(time.tv_usec) * 1.0e-6); | |
40 | |
41 #elif defined(WEBRTC_WIN) | |
42 struct _timeb time; | |
43 _ftime(&time); | |
44 // Convert from second (1.0) and milliseconds (1e-3). | |
45 return (static_cast<double>(time.time) + | |
46 static_cast<double>(time.millitm) * 1.0e-3); | |
47 #endif | |
48 } | |
49 | |
50 double Timing::TimerNow() { | |
51 return (static_cast<double>(TimeNanos()) / kNumNanosecsPerSec); | |
52 } | |
53 | |
54 } // namespace rtc | |
OLD | NEW |