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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 heap_state.used_new_space_size = kNewSpaceCapacity; | 149 heap_state.used_new_space_size = kNewSpaceCapacity; |
150 heap_state.scavenge_speed_in_bytes_per_ms = 1 * KB; | 150 heap_state.scavenge_speed_in_bytes_per_ms = 1 * KB; |
151 int idle_time_ms = 16; | 151 int idle_time_ms = 16; |
152 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoScavenge( | 152 EXPECT_FALSE(GCIdleTimeHandler::ShouldDoScavenge( |
153 idle_time_ms, heap_state.new_space_capacity, | 153 idle_time_ms, heap_state.new_space_capacity, |
154 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms, | 154 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms, |
155 heap_state.new_space_allocation_throughput_in_bytes_per_ms)); | 155 heap_state.new_space_allocation_throughput_in_bytes_per_ms)); |
156 } | 156 } |
157 | 157 |
158 | 158 |
| 159 TEST_F(GCIdleTimeHandlerTest, DoScavengeLowAllocationRate) { |
| 160 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
| 161 heap_state.used_new_space_size = kNewSpaceCapacity; |
| 162 heap_state.new_space_allocation_throughput_in_bytes_per_ms = |
| 163 GCIdleTimeHandler::kLowAllocationThroughput - 1; |
| 164 int idle_time_ms = 16; |
| 165 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge( |
| 166 idle_time_ms, heap_state.new_space_capacity, |
| 167 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms, |
| 168 heap_state.new_space_allocation_throughput_in_bytes_per_ms)); |
| 169 } |
| 170 |
| 171 |
159 TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) { | 172 TEST_F(GCIdleTimeHandlerTest, DoScavengeHighScavengeSpeed) { |
160 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); | 173 GCIdleTimeHandler::HeapState heap_state = DefaultHeapState(); |
161 heap_state.used_new_space_size = kNewSpaceCapacity; | 174 heap_state.used_new_space_size = kNewSpaceCapacity; |
162 heap_state.scavenge_speed_in_bytes_per_ms = kNewSpaceCapacity; | 175 heap_state.scavenge_speed_in_bytes_per_ms = kNewSpaceCapacity; |
163 int idle_time_ms = 16; | 176 int idle_time_ms = 16; |
164 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge( | 177 EXPECT_TRUE(GCIdleTimeHandler::ShouldDoScavenge( |
165 idle_time_ms, heap_state.new_space_capacity, | 178 idle_time_ms, heap_state.new_space_capacity, |
166 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms, | 179 heap_state.used_new_space_size, heap_state.scavenge_speed_in_bytes_per_ms, |
167 heap_state.new_space_allocation_throughput_in_bytes_per_ms)); | 180 heap_state.new_space_allocation_throughput_in_bytes_per_ms)); |
168 } | 181 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 // Simulate incremental marking stopped and not eligible to start. | 431 // Simulate incremental marking stopped and not eligible to start. |
419 heap_state.incremental_marking_stopped = true; | 432 heap_state.incremental_marking_stopped = true; |
420 double idle_time_ms = 10.0; | 433 double idle_time_ms = 10.0; |
421 // We should return DONE if we cannot start incremental marking. | 434 // We should return DONE if we cannot start incremental marking. |
422 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); | 435 GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state); |
423 EXPECT_EQ(DONE, action.type); | 436 EXPECT_EQ(DONE, action.type); |
424 } | 437 } |
425 | 438 |
426 } // namespace internal | 439 } // namespace internal |
427 } // namespace v8 | 440 } // namespace v8 |
OLD | NEW |