OLD | NEW |
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 14 matching lines...) Expand all Loading... |
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 return result; | 31 return result; |
32 } | 32 } |
33 | 33 |
34 static const size_t kSizeOfObjects = 100 * MB; | 34 static const size_t kSizeOfObjects = 100 * MB; |
35 static const size_t kMarkCompactSpeed = 100 * KB; | 35 static const size_t kMarkCompactSpeed = 200 * KB; |
36 static const size_t kMarkingSpeed = 100 * KB; | 36 static const size_t kMarkingSpeed = 200 * KB; |
37 | 37 |
38 private: | 38 private: |
39 GCIdleTimeHandler handler_; | 39 GCIdleTimeHandler handler_; |
40 }; | 40 }; |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 | 44 |
45 TEST(GCIdleTimeHandler, EstimateMarkingStepSizeInitial) { | 45 TEST(GCIdleTimeHandler, EstimateMarkingStepSizeInitial) { |
46 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0); | 46 size_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeInitial) { | 80 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeInitial) { |
81 size_t size = 100 * MB; | 81 size_t size = 100 * MB; |
82 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, 0); | 82 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, 0); |
83 EXPECT_EQ(size / GCIdleTimeHandler::kInitialConservativeMarkCompactSpeed, | 83 EXPECT_EQ(size / GCIdleTimeHandler::kInitialConservativeMarkCompactSpeed, |
84 time); | 84 time); |
85 } | 85 } |
86 | 86 |
87 | 87 |
88 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeNonZero) { | 88 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeNonZero) { |
89 size_t size = 100 * MB; | 89 size_t size = 100 * MB; |
90 size_t speed = 10 * KB; | 90 size_t speed = 1 * MB; |
91 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed); | 91 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed); |
92 EXPECT_EQ(size / speed, time); | 92 EXPECT_EQ(size / speed, time); |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeMax) { | 96 TEST(GCIdleTimeHandler, EstimateMarkCompactTimeMax) { |
97 size_t size = std::numeric_limits<size_t>::max(); | 97 size_t size = std::numeric_limits<size_t>::max(); |
98 size_t speed = 1; | 98 size_t speed = 1; |
99 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed); | 99 size_t time = GCIdleTimeHandler::EstimateMarkCompactTime(size, speed); |
100 EXPECT_EQ(GCIdleTimeHandler::kMaxMarkCompactTimeInMs, time); | 100 EXPECT_EQ(GCIdleTimeHandler::kMaxMarkCompactTimeInMs, time); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Emulate mutator work. | 235 // Emulate mutator work. |
236 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { | 236 for (int i = 0; i < GCIdleTimeHandler::kIdleScavengeThreshold; i++) { |
237 handler()->NotifyScavenge(); | 237 handler()->NotifyScavenge(); |
238 } | 238 } |
239 action = handler()->Compute(idle_time_ms, heap_state); | 239 action = handler()->Compute(idle_time_ms, heap_state); |
240 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); | 240 EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type); |
241 } | 241 } |
242 | 242 |
243 } // namespace internal | 243 } // namespace internal |
244 } // namespace v8 | 244 } // namespace v8 |
OLD | NEW |