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> |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 611 |
612 | 612 |
613 // static | 613 // static |
614 bool TimeTicks::IsHighResolutionClockWorking() { | 614 bool TimeTicks::IsHighResolutionClockWorking() { |
615 return true; | 615 return true; |
616 } | 616 } |
617 | 617 |
618 #endif // V8_OS_WIN | 618 #endif // V8_OS_WIN |
619 | 619 |
620 | 620 |
621 // TODO(lpy): For windows ThreadTicks implementation, | |
622 // see http://crbug.com/v8/5000 | |
623 bool ThreadTicks::IsSupported() { | 621 bool ThreadTicks::IsSupported() { |
624 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ | 622 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ |
625 defined(V8_OS_MACOSX) || defined(V8_OS_ANDROID) | 623 defined(V8_OS_MACOSX) || defined(V8_OS_ANDROID) |
626 return true; | 624 return true; |
| 625 #elif defined(V8_OS_WIN) |
| 626 return IsSupportedWin(); |
627 #else | 627 #else |
628 return false; | 628 return false; |
629 #endif | 629 #endif |
630 } | 630 } |
631 | 631 |
632 | 632 |
633 ThreadTicks ThreadTicks::Now() { | 633 ThreadTicks ThreadTicks::Now() { |
634 #if V8_OS_MACOSX | 634 #if V8_OS_MACOSX |
635 return ThreadTicks(ComputeThreadTicks()); | 635 return ThreadTicks(ComputeThreadTicks()); |
636 #elif(defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ | 636 #elif(defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ |
637 defined(V8_OS_ANDROID) | 637 defined(V8_OS_ANDROID) |
638 return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); | 638 return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 DCHECK_GE(tsc_now, tsc_initial); | 732 DCHECK_GE(tsc_now, tsc_initial); |
733 uint64_t tsc_ticks = tsc_now - tsc_initial; | 733 uint64_t tsc_ticks = tsc_now - tsc_initial; |
734 tsc_ticks_per_second = tsc_ticks / elapsed_time_seconds; | 734 tsc_ticks_per_second = tsc_ticks / elapsed_time_seconds; |
735 | 735 |
736 return tsc_ticks_per_second; | 736 return tsc_ticks_per_second; |
737 } | 737 } |
738 #endif // V8_OS_WIN | 738 #endif // V8_OS_WIN |
739 | 739 |
740 } // namespace base | 740 } // namespace base |
741 } // namespace v8 | 741 } // namespace v8 |
OLD | NEW |