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

Side by Side Diff: test/heap-unittests/heap-unittest.cc

Issue 496273002: First tests for GCIdleTimeHandler. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 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 "test/heap-unittests/heap-unittest.h"
6
5 #include <limits> 7 #include <limits>
6 8
7 #include "src/heap/gc-idle-time-handler.h"
8
9 #include "testing/gtest/include/gtest/gtest.h"
10 9
11 namespace v8 { 10 namespace v8 {
12 namespace internal { 11 namespace internal {
13 12
14 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeInitial) { 13 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeInitial) {
15 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0); 14 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0);
16 EXPECT_EQ( 15 EXPECT_EQ(
17 static_cast<size_t>(GCIdleTimeHandler::kInitialConservativeMarkingSpeed * 16 static_cast<size_t>(GCIdleTimeHandler::kInitialConservativeMarkingSpeed *
18 GCIdleTimeHandler::kConservativeTimeRatio), 17 GCIdleTimeHandler::kConservativeTimeRatio),
19 step_size); 18 step_size);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 61 }
63 62
64 63
65 TEST(EstimateMarkCompactTimeTest, EstimateMarkCompactTimeMax) { 64 TEST(EstimateMarkCompactTimeTest, EstimateMarkCompactTimeMax) {
66 size_t size = std::numeric_limits<size_t>::max(); 65 size_t size = std::numeric_limits<size_t>::max();
67 size_t speed = 1; 66 size_t speed = 1;
68 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed); 67 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed);
69 EXPECT_EQ(GCIdleTimeHandler::kMaxMarkCompactTimeInMs, time); 68 EXPECT_EQ(GCIdleTimeHandler::kMaxMarkCompactTimeInMs, time);
70 } 69 }
71 70
71
72 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) {
73 GCIdleTimeHandler::HeapState heap_state = initial_heap_state();
74 heap_state.contexts_disposed = 1;
75 heap_state.incremental_marking_stopped = true;
76 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
77 int idle_time_ms = (heap_state.size_of_objects + speed - 1) / speed;
78 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
79 EXPECT_EQ(DO_FULL_GC, action.type);
80 }
81
82
83 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) {
84 GCIdleTimeHandler::HeapState heap_state = initial_heap_state();
85 heap_state.contexts_disposed = 1;
86 heap_state.incremental_marking_stopped = true;
87 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
88 int idle_time_ms = heap_state.size_of_objects / speed - 1;
89 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
90 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
91 }
92
93
94 TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) {
95 GCIdleTimeHandler::HeapState heap_state = initial_heap_state();
96 heap_state.contexts_disposed = 1;
97 size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
98 int idle_time_ms = heap_state.size_of_objects / speed - 1;
99 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
100 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
101 }
102
103
72 } // namespace internal 104 } // namespace internal
73 } // namespace v8 105 } // namespace v8
OLDNEW
« test/heap-unittests/heap-unittest.h ('K') | « test/heap-unittests/heap-unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698