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

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

Issue 1023153002: Limit rate of full garbage collections triggered by idle notification. Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« test/cctest/test-api.cc ('K') | « test/cctest/test-api.cc ('k') | no next file » | 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 16 matching lines...) Expand all
27 result.incremental_marking_stopped = false; 27 result.incremental_marking_stopped = false;
28 result.can_start_incremental_marking = true; 28 result.can_start_incremental_marking = true;
29 result.sweeping_in_progress = false; 29 result.sweeping_in_progress = false;
30 result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed; 30 result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed;
31 result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed; 31 result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed;
32 result.scavenge_speed_in_bytes_per_ms = kScavengeSpeed; 32 result.scavenge_speed_in_bytes_per_ms = kScavengeSpeed;
33 result.used_new_space_size = 0; 33 result.used_new_space_size = 0;
34 result.new_space_capacity = kNewSpaceCapacity; 34 result.new_space_capacity = kNewSpaceCapacity;
35 result.new_space_allocation_throughput_in_bytes_per_ms = 35 result.new_space_allocation_throughput_in_bytes_per_ms =
36 kNewSpaceAllocationThroughput; 36 kNewSpaceAllocationThroughput;
37 result.last_mark_compact_time = 0;
38 result.current_time = GCIdleTimeHandler::kMinTimeInBetweenMarkCompactsInMs;
37 return result; 39 return result;
38 } 40 }
39 41
40 static const size_t kSizeOfObjects = 100 * MB; 42 static const size_t kSizeOfObjects = 100 * MB;
41 static const size_t kMarkCompactSpeed = 200 * KB; 43 static const size_t kMarkCompactSpeed = 200 * KB;
42 static const size_t kMarkingSpeed = 200 * KB; 44 static const size_t kMarkingSpeed = 200 * KB;
43 static const size_t kScavengeSpeed = 100 * KB; 45 static const size_t kScavengeSpeed = 100 * KB;
44 static const size_t kNewSpaceCapacity = 1 * MB; 46 static const size_t kNewSpaceCapacity = 1 * MB;
45 static const size_t kNewSpaceAllocationThroughput = 10 * KB; 47 static const size_t kNewSpaceAllocationThroughput = 10 * KB;
46 48
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 int idle_time_in_ms = 16; 164 int idle_time_in_ms = 16;
163 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge( 165 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge(
164 idle_time_in_ms, heap_state.new_space_capacity, 166 idle_time_in_ms, heap_state.new_space_capacity,
165 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms, 167 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms,
166 heap_state.new_space_allocation_throughput_in_bytes_per_ms)); 168 heap_state.new_space_allocation_throughput_in_bytes_per_ms));
167 } 169 }
168 170
169 171
170 TEST_F(GCIdleTimeHandlerTest, ShouldDoMarkCompact) { 172 TEST_F(GCIdleTimeHandlerTest, ShouldDoMarkCompact) {
171 size_t idle_time_in_ms = 16; 173 size_t idle_time_in_ms = 16;
172 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoMarkCompact(idle_time_in_ms, 0, 0)); 174 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoMarkCompact(
175 idle_time_in_ms, 0, 0, 0,
176 GCIdleTimeHandler::kMinTimeInBetweenMarkCompactsInMs));
173 } 177 }
174 178
175 179
176 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompact) { 180 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompact) {
177 size_t idle_time_in_ms = 1; 181 size_t idle_time_in_ms = 1;
178 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoMarkCompact( 182 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoMarkCompact(
179 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed)); 183 idle_time_in_ms, kSizeOfObjects, kMarkingSpeed, 0,
184 GCIdleTimeHandler::kMinTimeInBetweenMarkCompactsInMs));
180 } 185 }
181 186
182 187
188 TEST_F(GCIdleTimeHandlerTest, DontDoMarkCompactRate) {
189 size_t idle_time_in_ms = 16;
190 EXPECT_FALSE(
191 GCIdleTimeHandler::ShouldDoMarkCompact(idle_time_in_ms, 0, 0, 0, 0));
192 }
193
194
183 TEST_F(GCIdleTimeHandlerTest, ShouldDoFinalIncrementalMarkCompact) { 195 TEST_F(GCIdleTimeHandlerTest, ShouldDoFinalIncrementalMarkCompact) {
184 size_t idle_time_in_ms = 16; 196 size_t idle_time_in_ms = 16;
185 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( 197 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
186 idle_time_in_ms, 0, 0)); 198 idle_time_in_ms, 0, 0));
187 } 199 }
188 200
189 201
190 TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) { 202 TEST_F(GCIdleTimeHandlerTest, DontDoFinalIncrementalMarkCompact) {
191 size_t idle_time_in_ms = 1; 203 size_t idle_time_in_ms = 1;
192 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact( 204 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoFinalIncrementalMarkCompact(
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Emulate mutator work. 447 // Emulate mutator work.
436 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { 448 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
437 handler()->NotifyScavenge(); 449 handler()->NotifyScavenge();
438 } 450 }
439 action = handler()->Compute(0, heap_state); 451 action = handler()->Compute(0, heap_state);
440 EXPECT_EQ(DO_NOTHING, action.type); 452 EXPECT_EQ(DO_NOTHING, action.type);
441 } 453 }
442 454
443 } // namespace internal 455 } // namespace internal
444 } // namespace v8 456 } // namespace v8
OLDNEW
« test/cctest/test-api.cc ('K') | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698