OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/heap/gc-tracer.h" | 7 #include "src/heap/gc-tracer.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 durations += iter->duration_; | 608 durations += iter->duration_; |
609 ++iter; | 609 ++iter; |
610 } | 610 } |
611 | 611 |
612 if (durations == 0.0) return 0; | 612 if (durations == 0.0) return 0; |
613 | 613 |
614 return static_cast<size_t>(bytes / durations + 0.5); | 614 return static_cast<size_t>(bytes / durations + 0.5); |
615 } | 615 } |
616 | 616 |
617 | 617 |
618 size_t GCTracer::AllocatedBytesInLast(double time_ms) const { | 618 size_t GCTracer::AllocationThroughputInBytesPerMillisecond( |
| 619 double time_ms) const { |
619 size_t bytes = new_space_allocation_in_bytes_since_gc_ + | 620 size_t bytes = new_space_allocation_in_bytes_since_gc_ + |
620 old_generation_allocation_in_bytes_since_gc_; | 621 old_generation_allocation_in_bytes_since_gc_; |
621 double durations = allocation_duration_since_gc_; | 622 double durations = allocation_duration_since_gc_; |
622 AllocationEventBuffer::const_iterator iter = allocation_events_.begin(); | 623 AllocationEventBuffer::const_iterator iter = allocation_events_.begin(); |
623 const size_t max_bytes = static_cast<size_t>(-1); | 624 const size_t max_bytes = static_cast<size_t>(-1); |
624 while (iter != allocation_events_.end() && bytes < max_bytes - bytes && | 625 while (iter != allocation_events_.end() && bytes < max_bytes - bytes && |
625 durations < time_ms) { | 626 durations < time_ms) { |
626 bytes += iter->allocation_in_bytes_; | 627 bytes += iter->allocation_in_bytes_; |
627 durations += iter->duration_; | 628 durations += iter->duration_; |
628 ++iter; | 629 ++iter; |
629 } | 630 } |
630 | 631 |
631 if (durations == 0.0) return 0; | 632 if (durations == 0.0) return 0; |
632 | 633 |
633 bytes = static_cast<size_t>(bytes * (time_ms / durations) + 0.5); | 634 return static_cast<size_t>(bytes / durations + 0.5); |
634 // Return at least 1 since 0 means "no data". | |
635 return std::max<size_t>(bytes, 1); | |
636 } | 635 } |
637 | 636 |
638 | 637 |
639 size_t GCTracer::CurrentAllocationThroughputInBytesPerMillisecond() const { | 638 size_t GCTracer::CurrentAllocationThroughputInBytesPerMillisecond() const { |
640 static const double kThroughputTimeFrame = 5000; | 639 static const double kThroughputTimeFrame = 5000; |
641 size_t allocated_bytes = AllocatedBytesInLast(kThroughputTimeFrame); | 640 return AllocationThroughputInBytesPerMillisecond(kThroughputTimeFrame); |
642 if (allocated_bytes == 0) return 0; | |
643 return static_cast<size_t>((allocated_bytes / kThroughputTimeFrame) + 1); | |
644 } | 641 } |
645 | 642 |
646 | 643 |
647 double GCTracer::ContextDisposalRateInMilliseconds() const { | 644 double GCTracer::ContextDisposalRateInMilliseconds() const { |
648 if (context_disposal_events_.size() < kRingBufferMaxSize) return 0.0; | 645 if (context_disposal_events_.size() < kRingBufferMaxSize) return 0.0; |
649 | 646 |
650 double begin = base::OS::TimeCurrentMillis(); | 647 double begin = base::OS::TimeCurrentMillis(); |
651 double end = 0.0; | 648 double end = 0.0; |
652 ContextDisposalEventBuffer::const_iterator iter = | 649 ContextDisposalEventBuffer::const_iterator iter = |
653 context_disposal_events_.begin(); | 650 context_disposal_events_.begin(); |
(...skipping 21 matching lines...) Expand all Loading... |
675 | 672 |
676 | 673 |
677 bool GCTracer::SurvivalEventsRecorded() const { | 674 bool GCTracer::SurvivalEventsRecorded() const { |
678 return survival_events_.size() > 0; | 675 return survival_events_.size() > 0; |
679 } | 676 } |
680 | 677 |
681 | 678 |
682 void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); } | 679 void GCTracer::ResetSurvivalEvents() { survival_events_.reset(); } |
683 } | 680 } |
684 } // namespace v8::internal | 681 } // namespace v8::internal |
OLD | NEW |