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/globals.h" | 7 #include "src/globals.h" |
8 #include "src/heap/scavenge-job.h" | 8 #include "src/heap/scavenge-job.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 TEST(ScavengeJob, AllocationLimitHighScavengeSpeed) { | 64 TEST(ScavengeJob, AllocationLimitHighScavengeSpeed) { |
65 size_t scavenge_speed = kNewSpaceCapacity; | 65 size_t scavenge_speed = kNewSpaceCapacity; |
66 size_t expected_size = | 66 size_t expected_size = |
67 static_cast<size_t>( | 67 static_cast<size_t>( |
68 kNewSpaceCapacity * | 68 kNewSpaceCapacity * |
69 ScavengeJob::kMaxAllocationLimitAsFractionOfNewSpace) - | 69 ScavengeJob::kMaxAllocationLimitAsFractionOfNewSpace) - |
70 ScavengeJob::kBytesAllocatedBeforeNextIdleTask; | 70 ScavengeJob::kBytesAllocatedBeforeNextIdleTask; |
71 EXPECT_FALSE(ScavengeJob::ReachedIdleAllocationLimit( | 71 EXPECT_FALSE(ScavengeJob::ReachedIdleAllocationLimit( |
72 scavenge_speed, expected_size - 1, kNewSpaceCapacity)); | 72 scavenge_speed, expected_size - 1, kNewSpaceCapacity)); |
73 EXPECT_TRUE(ScavengeJob::ReachedIdleAllocationLimit( | 73 EXPECT_TRUE(ScavengeJob::ReachedIdleAllocationLimit( |
74 scavenge_speed, expected_size, kNewSpaceCapacity)); | 74 scavenge_speed, expected_size + 1, kNewSpaceCapacity)); |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 TEST(ScavengeJob, EnoughIdleTimeForScavengeUnknownScavengeSpeed) { | 78 TEST(ScavengeJob, EnoughIdleTimeForScavengeUnknownScavengeSpeed) { |
79 size_t scavenge_speed = ScavengeJob::kInitialScavengeSpeedInBytesPerMs; | 79 size_t scavenge_speed = ScavengeJob::kInitialScavengeSpeedInBytesPerMs; |
80 size_t new_space_size = 1 * MB; | 80 size_t new_space_size = 1 * MB; |
81 size_t expected_time = (new_space_size + scavenge_speed - 1) / scavenge_speed; | 81 size_t expected_time = (new_space_size + scavenge_speed - 1) / scavenge_speed; |
82 EXPECT_TRUE( | 82 EXPECT_TRUE( |
83 ScavengeJob::EnoughIdleTimeForScavenge(expected_time, 0, new_space_size)); | 83 ScavengeJob::EnoughIdleTimeForScavenge(expected_time, 0, new_space_size)); |
84 EXPECT_FALSE(ScavengeJob::EnoughIdleTimeForScavenge(expected_time - 1, 0, | 84 EXPECT_FALSE(ScavengeJob::EnoughIdleTimeForScavenge(expected_time - 1, 0, |
(...skipping 17 matching lines...) Expand all Loading... |
102 size_t new_space_size = 1 * MB; | 102 size_t new_space_size = 1 * MB; |
103 size_t expected_time = (new_space_size + scavenge_speed - 1) / scavenge_speed; | 103 size_t expected_time = (new_space_size + scavenge_speed - 1) / scavenge_speed; |
104 EXPECT_TRUE(ScavengeJob::EnoughIdleTimeForScavenge( | 104 EXPECT_TRUE(ScavengeJob::EnoughIdleTimeForScavenge( |
105 expected_time, scavenge_speed, new_space_size)); | 105 expected_time, scavenge_speed, new_space_size)); |
106 EXPECT_FALSE(ScavengeJob::EnoughIdleTimeForScavenge( | 106 EXPECT_FALSE(ScavengeJob::EnoughIdleTimeForScavenge( |
107 expected_time - 1, scavenge_speed, new_space_size)); | 107 expected_time - 1, scavenge_speed, new_space_size)); |
108 } | 108 } |
109 | 109 |
110 } // namespace internal | 110 } // namespace internal |
111 } // namespace v8 | 111 } // namespace v8 |
OLD | NEW |