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

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

Issue 580083002: Avoid idle times smaller than 1ms. (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') | 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 heap_state.incremental_marking_stopped = true; 308 heap_state.incremental_marking_stopped = true;
309 heap_state.available_new_space_memory = 309 heap_state.available_new_space_memory =
310 kNewSpaceAllocationThroughput * idle_time_ms; 310 kNewSpaceAllocationThroughput * idle_time_ms;
311 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); 311 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
312 EXPECT_EQ(DO_SCAVENGE, action.type); 312 EXPECT_EQ(DO_SCAVENGE, action.type);
313 heap_state.available_new_space_memory = kNewSpaceCapacity; 313 heap_state.available_new_space_memory = kNewSpaceCapacity;
314 action = handler()->Compute(idle_time_ms, heap_state); 314 action = handler()->Compute(idle_time_ms, heap_state);
315 EXPECT_EQ(DO_NOTHING, action.type); 315 EXPECT_EQ(DO_NOTHING, action.type);
316 } 316 }
317 317
318
319 TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeNothingToDo) {
320 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
321 int idle_time_ms = 0;
322 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
323 EXPECT_EQ(DO_NOTHING, action.type);
324 }
325
326
327 TEST_F(GCIdleTimeHandlerTest, ZeroIdleTimeDoNothingButStartIdleRound) {
328 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState();
329 int idle_time_ms = 10;
330 for (int i = 0; i < GCIdleTimeHandler::kMaxMarkCompactsInIdleRound; i++) {
331 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
332 if (action.type == DONE) break;
333 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
334 // In this case we try to emulate incremental marking steps the finish with
335 // a full gc.
336 handler()->NotifyIdleMarkCompact();
337 }
338 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
339 // Emulate mutator work.
340 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) {
341 handler()->NotifyScavenge();
342 }
343 action = handler()->Compute(0, heap_state);
344 EXPECT_EQ(DO_NOTHING, action.type);
345 }
346
318 } // namespace internal 347 } // namespace internal
319 } // namespace v8 348 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/gc-idle-time-handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698