OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/time/time.h" | 5 #include "base/time/time.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <ios> | 8 #include <ios> |
9 #include <limits> | 9 #include <limits> |
10 #include <ostream> | 10 #include <ostream> |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 std::ostream& operator<<(std::ostream& os, TimeTicks time_ticks) { | 320 std::ostream& operator<<(std::ostream& os, TimeTicks time_ticks) { |
321 // This function formats a TimeTicks object as "bogo-microseconds". | 321 // This function formats a TimeTicks object as "bogo-microseconds". |
322 // The origin and granularity of the count are platform-specific, and may very | 322 // The origin and granularity of the count are platform-specific, and may very |
323 // from run to run. Although bogo-microseconds usually roughly correspond to | 323 // from run to run. Although bogo-microseconds usually roughly correspond to |
324 // real microseconds, the only real guarantee is that the number never goes | 324 // real microseconds, the only real guarantee is that the number never goes |
325 // down during a single run. | 325 // down during a single run. |
326 const TimeDelta as_time_delta = time_ticks - TimeTicks(); | 326 const TimeDelta as_time_delta = time_ticks - TimeTicks(); |
327 return os << as_time_delta.InMicroseconds() << " bogo-microseconds"; | 327 return os << as_time_delta.InMicroseconds() << " bogo-microseconds"; |
328 } | 328 } |
329 | 329 |
| 330 std::ostream& operator<<(std::ostream& os, ThreadTicks thread_ticks) { |
| 331 const TimeDelta as_time_delta = thread_ticks - ThreadTicks(); |
| 332 return os << as_time_delta.InMicroseconds() << " bogo-thread-microseconds"; |
| 333 } |
| 334 |
| 335 std::ostream& operator<<(std::ostream& os, TraceTicks trace_ticks) { |
| 336 const TimeDelta as_time_delta = trace_ticks - TraceTicks(); |
| 337 return os << as_time_delta.InMicroseconds() << " bogo-trace-microseconds"; |
| 338 } |
| 339 |
330 // Time::Exploded ------------------------------------------------------------- | 340 // Time::Exploded ------------------------------------------------------------- |
331 | 341 |
332 inline bool is_in_range(int value, int lo, int hi) { | 342 inline bool is_in_range(int value, int lo, int hi) { |
333 return lo <= value && value <= hi; | 343 return lo <= value && value <= hi; |
334 } | 344 } |
335 | 345 |
336 bool Time::Exploded::HasValidValues() const { | 346 bool Time::Exploded::HasValidValues() const { |
337 return is_in_range(month, 1, 12) && | 347 return is_in_range(month, 1, 12) && |
338 is_in_range(day_of_week, 0, 6) && | 348 is_in_range(day_of_week, 0, 6) && |
339 is_in_range(day_of_month, 1, 31) && | 349 is_in_range(day_of_month, 1, 31) && |
340 is_in_range(hour, 0, 23) && | 350 is_in_range(hour, 0, 23) && |
341 is_in_range(minute, 0, 59) && | 351 is_in_range(minute, 0, 59) && |
342 is_in_range(second, 0, 60) && | 352 is_in_range(second, 0, 60) && |
343 is_in_range(millisecond, 0, 999); | 353 is_in_range(millisecond, 0, 999); |
344 } | 354 } |
345 | 355 |
346 } // namespace base | 356 } // namespace base |
OLD | NEW |