OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
3 * Copyright (C) 2008 Google Inc. All rights reserved. | 3 * Copyright (C) 2008 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Returns the current UTC time in seconds, counted from January 1, 1970. | 39 // Returns the current UTC time in seconds, counted from January 1, 1970. |
40 // Precision varies depending on platform but is usually as good or better | 40 // Precision varies depending on platform but is usually as good or better |
41 // than a millisecond. | 41 // than a millisecond. |
42 WTF_EXPORT double currentTime(); | 42 WTF_EXPORT double currentTime(); |
43 | 43 |
44 // Same thing, in milliseconds. | 44 // Same thing, in milliseconds. |
45 inline double currentTimeMS() { | 45 inline double currentTimeMS() { |
46 return currentTime() * 1000.0; | 46 return currentTime() * 1000.0; |
47 } | 47 } |
48 | 48 |
49 // Provides a monotonically increasing time in seconds since an arbitrary point
in the past. | 49 // Provides a monotonically increasing time in seconds since an arbitrary point |
50 // On unsupported platforms, this function only guarantees the result will be no
n-decreasing. | 50 // in the past. On unsupported platforms, this function only guarantees the |
| 51 // result will be non-decreasing. |
51 WTF_EXPORT double monotonicallyIncreasingTime(); | 52 WTF_EXPORT double monotonicallyIncreasingTime(); |
52 | 53 |
53 // Same thing, in milliseconds. | 54 // Same thing, in milliseconds. |
54 inline double monotonicallyIncreasingTimeMS() { | 55 inline double monotonicallyIncreasingTimeMS() { |
55 return monotonicallyIncreasingTime() * 1000.0; | 56 return monotonicallyIncreasingTime() * 1000.0; |
56 } | 57 } |
57 | 58 |
58 using TimeFunction = double (*)(); | 59 using TimeFunction = double (*)(); |
59 | 60 |
60 // Make all the time functions (currentTime(), monotonicallyIncreasingTime(), sy
stemTraceTime()) return the result | 61 // Make all the time functions (currentTime(), monotonicallyIncreasingTime(), |
61 // of the supplied function. Returns the pointer to the old time function. For b
oth setting and getting, nullptr means | 62 // systemTraceTime()) return the result of the supplied function. Returns the |
62 // using the default timing function returning the actual time. | 63 // pointer to the old time function. For both setting and getting, nullptr |
| 64 // means using the default timing function returning the actual time. |
63 WTF_EXPORT TimeFunction setTimeFunctionsForTesting(TimeFunction); | 65 WTF_EXPORT TimeFunction setTimeFunctionsForTesting(TimeFunction); |
64 | 66 |
65 } // namespace WTF | 67 } // namespace WTF |
66 | 68 |
67 using WTF::currentTime; | 69 using WTF::currentTime; |
68 using WTF::currentTimeMS; | 70 using WTF::currentTimeMS; |
69 using WTF::monotonicallyIncreasingTime; | 71 using WTF::monotonicallyIncreasingTime; |
70 using WTF::monotonicallyIncreasingTimeMS; | 72 using WTF::monotonicallyIncreasingTimeMS; |
71 using WTF::TimeFunction; | 73 using WTF::TimeFunction; |
72 using WTF::setTimeFunctionsForTesting; | 74 using WTF::setTimeFunctionsForTesting; |
73 | 75 |
74 #endif // CurrentTime_h | 76 #endif // CurrentTime_h |
OLD | NEW |