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