Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Side by Side Diff: runtime/vm/pages.cc

Issue 247793004: RingBuffer<T, N> utility with unit test; use for GC history. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/pages.h" 5 #include "vm/pages.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/compiler_stats.h" 8 #include "vm/compiler_stats.h"
9 #include "vm/gc_marker.h" 9 #include "vm/gc_marker.h"
10 #include "vm/gc_sweeper.h" 10 #include "vm/gc_sweeper.h"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 PageSpace::kPageSizeInWords; 709 PageSpace::kPageSizeInWords;
710 grow_heap_ = Utils::Maximum(grow_heap_, freed_pages / 2); 710 grow_heap_ = Utils::Maximum(grow_heap_, freed_pages / 2);
711 heap->RecordData(PageSpace::kGarbageRatio, collected_garbage_ratio); 711 heap->RecordData(PageSpace::kGarbageRatio, collected_garbage_ratio);
712 heap->RecordData(PageSpace::kGCTimeFraction, 712 heap->RecordData(PageSpace::kGCTimeFraction,
713 garbage_collection_time_fraction); 713 garbage_collection_time_fraction);
714 heap->RecordData(PageSpace::kAllowedGrowth, grow_heap_); 714 heap->RecordData(PageSpace::kAllowedGrowth, grow_heap_);
715 last_usage_ = after; 715 last_usage_ = after;
716 } 716 }
717 717
718 718
719 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory()
720 : index_(0) {
721 for (intptr_t i = 0; i < kHistoryLength; i++) {
722 start_[i] = 0;
723 end_[i] = 0;
724 }
725 }
726
727
728 void PageSpaceGarbageCollectionHistory:: 719 void PageSpaceGarbageCollectionHistory::
729 AddGarbageCollectionTime(int64_t start, int64_t end) { 720 AddGarbageCollectionTime(int64_t start, int64_t end) {
730 int index = index_ % kHistoryLength; 721 Entry entry;
731 start_[index] = start; 722 entry.start = start;
732 end_[index] = end; 723 entry.end = end;
733 index_++; 724 history_.Add(entry);
734 } 725 }
735 726
736 727
737 int PageSpaceGarbageCollectionHistory::GarbageCollectionTimeFraction() { 728 int PageSpaceGarbageCollectionHistory::GarbageCollectionTimeFraction() {
738 int current;
739 int previous;
740 int64_t gc_time = 0; 729 int64_t gc_time = 0;
741 int64_t total_time = 0; 730 int64_t total_time = 0;
742 for (intptr_t i = 1; i < kHistoryLength; i++) { 731 for (int i = 0; i < history_.Size() - 1; i++) {
743 current = (index_ - i) % kHistoryLength; 732 Entry current = history_.Get(i);
744 previous = (index_ - 1 - i) % kHistoryLength; 733 Entry previous = history_.Get(i + 1);
745 if (end_[previous] == 0) { 734 gc_time += current.end - current.start;
746 break; 735 total_time += current.end - previous.end;
747 }
748 // iterate over the circular buffer in reverse order
749 gc_time += end_[current] - start_[current];
750 total_time += end_[current] - end_[previous];
751 } 736 }
752 if (total_time == 0) { 737 if (total_time == 0) {
753 return 0; 738 return 0;
754 } else { 739 } else {
755 ASSERT(total_time >= gc_time); 740 ASSERT(total_time >= gc_time);
756 int result= static_cast<int>((static_cast<double>(gc_time) / 741 int result= static_cast<int>((static_cast<double>(gc_time) /
757 static_cast<double>(total_time)) * 100); 742 static_cast<double>(total_time)) * 100);
758 return result; 743 return result;
759 } 744 }
760 } 745 }
761 746
762 } // namespace dart 747 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/ring_buffer.h » ('j') | runtime/vm/ring_buffer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698