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 <climits> |
| 6 |
| 7 #include "src/heap/gc-idle-time-handler.h" |
| 8 |
5 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
6 | 10 |
7 namespace v8 { | 11 namespace v8 { |
8 namespace internal { | 12 namespace internal { |
9 | 13 |
10 TEST(HeapTest, Dummy) { | 14 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeInitial) { |
11 EXPECT_FALSE(false); | 15 intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(1, 0); |
12 EXPECT_TRUE(true); | 16 EXPECT_EQ(static_cast<intptr_t>( |
| 17 GCIdleTimeHandler::kInitialConservativeMarkingSpeed * |
| 18 GCIdleTimeHandler::kConservativeTimeRatio), |
| 19 step_size); |
| 20 } |
| 21 |
| 22 |
| 23 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeNonZero) { |
| 24 intptr_t marking_speed_in_bytes_per_millisecond = 100; |
| 25 intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize( |
| 26 1, marking_speed_in_bytes_per_millisecond); |
| 27 EXPECT_EQ(static_cast<intptr_t>(marking_speed_in_bytes_per_millisecond * |
| 28 GCIdleTimeHandler::kConservativeTimeRatio), |
| 29 step_size); |
| 30 } |
| 31 |
| 32 |
| 33 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow1) { |
| 34 intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(10, INT_MAX); |
| 35 EXPECT_EQ(INT_MAX, step_size); |
| 36 } |
| 37 |
| 38 |
| 39 TEST(EstimateMarkingStepSizeTest, EstimateMarkingStepSizeOverflow2) { |
| 40 intptr_t step_size = GCIdleTimeHandler::EstimateMarkingStepSize(INT_MAX, 10); |
| 41 EXPECT_EQ(INT_MAX, step_size); |
13 } | 42 } |
14 | 43 |
15 } // namespace internal | 44 } // namespace internal |
16 } // namespace v8 | 45 } // namespace v8 |
OLD | NEW |