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