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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/ring_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.cc
===================================================================
--- runtime/vm/pages.cc (revision 35210)
+++ runtime/vm/pages.cc (working copy)
@@ -716,38 +716,23 @@
}
-PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory()
- : index_(0) {
- for (intptr_t i = 0; i < kHistoryLength; i++) {
- start_[i] = 0;
- end_[i] = 0;
- }
-}
-
-
void PageSpaceGarbageCollectionHistory::
AddGarbageCollectionTime(int64_t start, int64_t end) {
- int index = index_ % kHistoryLength;
- start_[index] = start;
- end_[index] = end;
- index_++;
+ Entry entry;
+ entry.start = start;
+ entry.end = end;
+ history_.Add(entry);
}
int PageSpaceGarbageCollectionHistory::GarbageCollectionTimeFraction() {
- int current;
- int previous;
int64_t gc_time = 0;
int64_t total_time = 0;
- for (intptr_t i = 1; i < kHistoryLength; i++) {
- current = (index_ - i) % kHistoryLength;
- previous = (index_ - 1 - i) % kHistoryLength;
- if (end_[previous] == 0) {
- break;
- }
- // iterate over the circular buffer in reverse order
- gc_time += end_[current] - start_[current];
- total_time += end_[current] - end_[previous];
+ for (int i = 0; i < history_.Size() - 1; i++) {
+ Entry current = history_.Get(i);
+ Entry previous = history_.Get(i + 1);
+ gc_time += current.end - current.start;
+ total_time += current.end - previous.end;
}
if (total_time == 0) {
return 0;
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/ring_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698