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

Unified Diff: test/unittests/heap/heap-unittest.cc

Issue 1163143009: Compute the heap growing factor based on mutator utilization and allocation throughput. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add missing file Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/heap/heap-unittest.cc
diff --git a/test/unittests/heap/heap-unittest.cc b/test/unittests/heap/heap-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9492faf9f34206300a211ba482a0b7263d9678c5
--- /dev/null
+++ b/test/unittests/heap/heap-unittest.cc
@@ -0,0 +1,48 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cmath>
+#include <limits>
+
+#include "src/objects.h"
+#include "src/objects-inl.h"
+
+#include "src/handles.h"
+#include "src/handles-inl.h"
+
+#include "src/heap/heap.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+
+double Round(double x) {
+ // Round to three digits.
+ return floor(x * 1000 + 0.5) / 1000;
+}
+
+
+void CheckEqualRounded(double expected, double actual) {
+ expected = Round(expected);
+ actual = Round(actual);
+ EXPECT_DOUBLE_EQ(expected, actual);
+}
+
+
+TEST(Heap, HeapGrowingFactor) {
+ CheckEqualRounded(Heap::kMaxHeapGrowingFactor,
+ Heap::HeapGrowingFactor(34, 1));
+ CheckEqualRounded(3.553, Heap::HeapGrowingFactor(45, 1));
+ CheckEqualRounded(2.830, Heap::HeapGrowingFactor(50, 1));
+ CheckEqualRounded(1.478, Heap::HeapGrowingFactor(100, 1));
+ CheckEqualRounded(1.193, Heap::HeapGrowingFactor(200, 1));
+ CheckEqualRounded(1.121, Heap::HeapGrowingFactor(300, 1));
+ CheckEqualRounded(Heap::HeapGrowingFactor(300, 1),
+ Heap::HeapGrowingFactor(600, 2));
+ CheckEqualRounded(Heap::kMinHeapGrowingFactor,
+ Heap::HeapGrowingFactor(400, 1));
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/heap/heap.cc ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698