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

Side by Side Diff: src/heap/gc-idle-time-handler-unittest.cc

Issue 563493002: Allow IdleNotification to trigger Scavenges. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <limits> 5 #include <limits>
6 6
7 #include "src/heap/gc-idle-time-handler.h" 7 #include "src/heap/gc-idle-time-handler.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 10 matching lines...) Expand all
21 21
22 GCIdleTimeHandler::HeapState DefaultHeapState() { 22 GCIdleTimeHandler::HeapState DefaultHeapState() {
23 GCIdleTimeHandler::HeapState result; 23 GCIdleTimeHandler::HeapState result;
24 result.contexts_disposed = 0; 24 result.contexts_disposed = 0;
25 result.size_of_objects = kSizeOfObjects; 25 result.size_of_objects = kSizeOfObjects;
26 result.incremental_marking_stopped = false; 26 result.incremental_marking_stopped = false;
27 result.can_start_incremental_marking = true; 27 result.can_start_incremental_marking = true;
28 result.sweeping_in_progress = false; 28 result.sweeping_in_progress = false;
29 result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed; 29 result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed;
30 result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed; 30 result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed;
31 result.scavenge_speed_in_bytes_per_ms = kScavengeSpeed;
32 result.available_new_space_memory = kNewSpaceCapacity;
33 result.new_space_capacity = kNewSpaceCapacity;
31 return result; 34 return result;
32 } 35 }
33 36
34 static const size_t kSizeOfObjects = 100 * MB; 37 static const size_t kSizeOfObjects = 100 * MB;
35 static const size_t kMarkCompactSpeed = 100 * KB; 38 static const size_t kMarkCompactSpeed = 100 * KB;
36 static const size_t kMarkingSpeed = 100 * KB; 39 static const size_t kMarkingSpeed = 100 * KB;
40 static const size_t kScavengeSpeed = 100 * KB;
41 static const size_t kNewSpaceCapacity = 1 * MB;
37 42
38 private: 43 private:
39 GCIdleTimeHandler handler_; 44 GCIdleTimeHandler handler_;
40 }; 45 };
41 46
42 } // namespace 47 } // namespace
43 48
44 49
45 TEST(GCIdleTimeHandler, EstimateMarkingStepSizeInitial) { 50 TEST(GCIdleTimeHandler, EstimateMarkingStepSizeInitial) {
46 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0); 51 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 99
95 100
96 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeMax) { 101 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeMax) {
97 size_t size = std::numeric_limits<size_t>::max(); 102 size_t size = std::numeric_limits<size_t>::max();
98 size_t speed = 1; 103 size_t speed = 1;
99 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed); 104 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed);
100 EXPECT_EQ(GCIdleTimeHandler::kMaxMarkCompactTimeInMs, time); 105 EXPECT_EQ(GCIdleTimeHandler::kMaxMarkCompactTimeInMs, time);
101 } 106 }
102 107
103 108
109 TEST(GCIdleTimeHandler, EstimateScavengeTimeInitial) {
110 size_t size = 1 * MB;
111 size_t time = GCIdleTimeHandler::EstimateScavengeTime(size, 0);
112 EXPECT_EQ(size / GCIdleTimeHandler::kInitialConservativeScavengeSpeed, time);
113 }
114
115
116 TEST(GCIdleTimeHandler, EstimateScavengeTimeNonZero) {
117 size_t size = 1 * MB;
118 size_t speed = 1 * MB;
119 size_t time = GCIdleTimeHandler::EstimateScavengeTime(size, speed);
120 EXPECT_EQ(size / speed, time);
121 }
122
123
104 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) { 124 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) {
105 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); 125 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
106 heap_state.contexts_disposed = 1; 126 heap_state.contexts_disposed = 1;
107 heap_state.incremental_marking_stopped = true; 127 heap_state.incremental_marking_stopped = true;
108 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms; 128 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
109 int idle_time_ms = 129 int idle_time_ms =
110 static_cast<int>((heap_state.size_of_objects + speed - 1) / speed); 130 static_cast<int>((heap_state.size_of_objects + speed - 1) / speed);
111 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 131 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
112 EXPECT_EQ(DO_FULL_GC, action.type); 132 EXPECT_EQ(DO_FULL_GC, action.type);
113 } 133 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // Emulate mutator work. 255 // Emulate mutator work.
236 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { 256 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
237 handler()->NotifyScavenge(); 257 handler()->NotifyScavenge();
238 } 258 }
239 action = handler()->Compute(idle_time_ms, heap_state); 259 action = handler()->Compute(idle_time_ms, heap_state);
240 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); 260 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
241 } 261 }
242 262
243 } // namespace internal 263 } // namespace internal
244 } // namespace v8 264 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | src/heap/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698