OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project 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 "src/base/platform/time.h" | 5 #include "src/base/platform/time.h" |
6 | 6 |
7 #if V8_OS_POSIX | 7 #if V8_OS_POSIX |
8 #include <fcntl.h> // for O_RDONLY | 8 #include <fcntl.h> // for O_RDONLY |
9 #include <sys/time.h> | 9 #include <sys/time.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
11 #endif | 11 #endif |
12 #if V8_OS_MACOSX | 12 #if V8_OS_MACOSX |
13 #include <mach/mach_time.h> | 13 #include <mach/mach_time.h> |
14 #endif | 14 #endif |
15 | 15 |
16 #include <string.h> | 16 #include <cstring> |
| 17 #include <ostream> |
17 | 18 |
18 #if V8_OS_WIN | 19 #if V8_OS_WIN |
19 #include "src/base/lazy-instance.h" | 20 #include "src/base/lazy-instance.h" |
20 #include "src/base/win32-headers.h" | 21 #include "src/base/win32-headers.h" |
21 #endif | 22 #endif |
22 #include "src/base/cpu.h" | 23 #include "src/base/cpu.h" |
23 #include "src/base/logging.h" | 24 #include "src/base/logging.h" |
24 #include "src/base/platform/platform.h" | 25 #include "src/base/platform/platform.h" |
25 | 26 |
26 namespace v8 { | 27 namespace v8 { |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 return 0; | 349 return 0; |
349 } | 350 } |
350 if (IsMax()) { | 351 if (IsMax()) { |
351 // Preserve max without offset to prevent overflow. | 352 // Preserve max without offset to prevent overflow. |
352 return std::numeric_limits<double>::max(); | 353 return std::numeric_limits<double>::max(); |
353 } | 354 } |
354 return static_cast<double>(us_) / kMicrosecondsPerMillisecond; | 355 return static_cast<double>(us_) / kMicrosecondsPerMillisecond; |
355 } | 356 } |
356 | 357 |
357 | 358 |
| 359 std::ostream& operator<<(std::ostream& os, const Time& time) { |
| 360 return os << time.ToJsTime(); |
| 361 } |
| 362 |
| 363 |
358 #if V8_OS_WIN | 364 #if V8_OS_WIN |
359 | 365 |
360 class TickClock { | 366 class TickClock { |
361 public: | 367 public: |
362 virtual ~TickClock() {} | 368 virtual ~TickClock() {} |
363 virtual int64_t Now() = 0; | 369 virtual int64_t Now() = 0; |
364 virtual bool IsHighResolution() = 0; | 370 virtual bool IsHighResolution() = 0; |
365 }; | 371 }; |
366 | 372 |
367 | 373 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 | 647 |
642 | 648 |
643 // static | 649 // static |
644 bool TimeTicks::KernelTimestampAvailable() { | 650 bool TimeTicks::KernelTimestampAvailable() { |
645 return kernel_tick_clock.Pointer()->Available(); | 651 return kernel_tick_clock.Pointer()->Available(); |
646 } | 652 } |
647 | 653 |
648 #endif // V8_OS_WIN | 654 #endif // V8_OS_WIN |
649 | 655 |
650 } } // namespace v8::base | 656 } } // namespace v8::base |
OLD | NEW |