Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: test/unittests/heap/heap-unittest.cc

Issue 2919023003: [heap] Scale max heap growing factor. (Closed)
Patch Set: tests Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <cmath> 5 #include <cmath>
6 #include <iostream> 6 #include <iostream>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/objects.h" 9 #include "src/objects.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 15 matching lines...) Expand all
26 26
27 void CheckEqualRounded(double expected, double actual) { 27 void CheckEqualRounded(double expected, double actual) {
28 expected = Round(expected); 28 expected = Round(expected);
29 actual = Round(actual); 29 actual = Round(actual);
30 EXPECT_DOUBLE_EQ(expected, actual); 30 EXPECT_DOUBLE_EQ(expected, actual);
31 } 31 }
32 32
33 33
34 TEST(Heap, HeapGrowingFactor) { 34 TEST(Heap, HeapGrowingFactor) {
35 CheckEqualRounded(Heap::kMaxHeapGrowingFactor, 35 CheckEqualRounded(Heap::kMaxHeapGrowingFactor,
36 Heap::HeapGrowingFactor(34, 1)); 36 Heap::HeapGrowingFactor(34, 1, 4.0));
37 CheckEqualRounded(3.553, Heap::HeapGrowingFactor(45, 1)); 37 CheckEqualRounded(3.553, Heap::HeapGrowingFactor(45, 1, 4.0));
38 CheckEqualRounded(2.830, Heap::HeapGrowingFactor(50, 1)); 38 CheckEqualRounded(2.830, Heap::HeapGrowingFactor(50, 1, 4.0));
39 CheckEqualRounded(1.478, Heap::HeapGrowingFactor(100, 1)); 39 CheckEqualRounded(1.478, Heap::HeapGrowingFactor(100, 1, 4.0));
40 CheckEqualRounded(1.193, Heap::HeapGrowingFactor(200, 1)); 40 CheckEqualRounded(1.193, Heap::HeapGrowingFactor(200, 1, 4.0));
41 CheckEqualRounded(1.121, Heap::HeapGrowingFactor(300, 1)); 41 CheckEqualRounded(1.121, Heap::HeapGrowingFactor(300, 1, 4.0));
42 CheckEqualRounded(Heap::HeapGrowingFactor(300, 1), 42 CheckEqualRounded(Heap::HeapGrowingFactor(300, 1, 4.0),
43 Heap::HeapGrowingFactor(600, 2)); 43 Heap::HeapGrowingFactor(600, 2, 4.0));
44 CheckEqualRounded(Heap::kMinHeapGrowingFactor, 44 CheckEqualRounded(Heap::kMinHeapGrowingFactor,
45 Heap::HeapGrowingFactor(400, 1)); 45 Heap::HeapGrowingFactor(400, 1, 4.0));
46 }
47
48 TEST(Heap, MaxHeapGrowingFactor) {
49 CheckEqualRounded(
50 1.3, Heap::MaxHeapGrowingFactor(Heap::kMinOldGenerationSize * MB));
51 CheckEqualRounded(
52 1.600, Heap::MaxHeapGrowingFactor(Heap::kMaxOldGenerationSize / 2 * MB));
53 CheckEqualRounded(
54 1.999,
55 Heap::MaxHeapGrowingFactor(
56 (Heap::kMaxOldGenerationSize - Heap::kPointerMultiplier) * MB));
57 CheckEqualRounded(4.0,
58 Heap::MaxHeapGrowingFactor(
59 static_cast<size_t>(Heap::kMaxOldGenerationSize) * MB));
46 } 60 }
47 61
48 TEST(Heap, SemiSpaceSize) { 62 TEST(Heap, SemiSpaceSize) {
49 uint64_t configurations[][2] = { 63 uint64_t configurations[][2] = {
50 {0, 1 * i::Heap::kPointerMultiplier}, 64 {0, 1 * i::Heap::kPointerMultiplier},
51 {512 * i::MB, 1 * i::Heap::kPointerMultiplier}, 65 {512 * i::MB, 1 * i::Heap::kPointerMultiplier},
52 {1 * i::GB, 3 * i::Heap::kPointerMultiplier}, 66 {1 * i::GB, 3 * i::Heap::kPointerMultiplier},
53 {2 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}, 67 {2 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize},
54 {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}, 68 {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize},
55 {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}}; 69 {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxSemiSpaceSize}};
56 70
57 for (auto configuration : configurations) { 71 for (auto configuration : configurations) {
58 ASSERT_EQ(configuration[1], 72 ASSERT_EQ(configuration[1],
59 static_cast<uint64_t>( 73 static_cast<uint64_t>(
60 i::Heap::ComputeMaxSemiSpaceSize(configuration[0]))); 74 i::Heap::ComputeMaxSemiSpaceSize(configuration[0])));
61 } 75 }
62 } 76 }
63 77
64 TEST(Heap, OldGenerationSize) { 78 TEST(Heap, OldGenerationSize) {
65 uint64_t configurations[][2] = { 79 uint64_t configurations[][2] = {
66 {0, i::Heap::kMinOldSpaceSize}, 80 {0, i::Heap::kMinOldGenerationSize},
67 {512, i::Heap::kMinOldSpaceSize}, 81 {512, i::Heap::kMinOldGenerationSize},
68 {1 * i::GB, 256 * i::Heap::kPointerMultiplier}, 82 {1 * i::GB, 256 * i::Heap::kPointerMultiplier},
69 {2 * static_cast<uint64_t>(i::GB), 512 * i::Heap::kPointerMultiplier}, 83 {2 * static_cast<uint64_t>(i::GB), 512 * i::Heap::kPointerMultiplier},
70 {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxOldSpaceSize}, 84 {4 * static_cast<uint64_t>(i::GB), i::Heap::kMaxOldGenerationSize},
71 {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxOldSpaceSize}}; 85 {8 * static_cast<uint64_t>(i::GB), i::Heap::kMaxOldGenerationSize}};
72 86
73 for (auto configuration : configurations) { 87 for (auto configuration : configurations) {
74 ASSERT_EQ(configuration[1], 88 ASSERT_EQ(configuration[1],
75 static_cast<uint64_t>( 89 static_cast<uint64_t>(
76 i::Heap::ComputeMaxOldGenerationSize(configuration[0]))); 90 i::Heap::ComputeMaxOldGenerationSize(configuration[0])));
77 } 91 }
78 } 92 }
79 93
80 } // namespace internal 94 } // namespace internal
81 } // namespace v8 95 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698