Reviewers: Hannes Payer,
Message:
PTAL. More tests will follow.
Description:
First tests for GCIdleTimeHandler.
BUG=
Please review this at https://codereview.chromium.org/496273002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+76, -3 lines):
A test/heap-unittests/heap-unittest.h
M test/heap-unittests/heap-unittest.cc
Index: test/heap-unittests/heap-unittest.cc
diff --git a/test/heap-unittests/heap-unittest.cc
b/test/heap-unittests/heap-unittest.cc
index
f51908bc1ab13ba8d53daddfae516564bcefe2b5..a90d4278c382744d8de1bf34fa65f2cbe019636f
100644
--- a/test/heap-unittests/heap-unittest.cc
+++ b/test/heap-unittests/heap-unittest.cc
@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <limits>
+#include "test/heap-unittests/heap-unittest.h"
-#include "src/heap/gc-idle-time-handler.h"
+#include <limits>
-#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
@@ -69,5 +68,38 @@ TEST(EstimateMarkCompactTimeTest,
EstimateMarkCompactTimeMax) {
EXPECT_EQ(GCIdleTimeHandler::kMaxMarkCompactTimeInMs, time);
}
+
+TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeLargeIdleTime) {
+ GCIdleTimeHandler::HeapState heap_state = initial_heap_state();
+ heap_state.contexts_disposed = 1;
+ heap_state.incremental_marking_stopped = true;
+ size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
+ int idle_time_ms = (heap_state.size_of_objects + speed - 1) / speed;
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+ EXPECT_EQ(DO_FULL_GC, action.type);
+}
+
+
+TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime1) {
+ GCIdleTimeHandler::HeapState heap_state = initial_heap_state();
+ heap_state.contexts_disposed = 1;
+ heap_state.incremental_marking_stopped = true;
+ size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
+ int idle_time_ms = heap_state.size_of_objects / speed - 1;
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+ EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
+}
+
+
+TEST_F(GCIdleTimeHandlerTest, AfterContextDisposeSmallIdleTime2) {
+ GCIdleTimeHandler::HeapState heap_state = initial_heap_state();
+ heap_state.contexts_disposed = 1;
+ size_t speed = heap_state.mark_compact_speed_in_bytes_per_ms;
+ int idle_time_ms = heap_state.size_of_objects / speed - 1;
+ GCIdleTimeAction action = handler()->Compute(idle_time_ms, heap_state);
+ EXPECT_EQ(DO_INCREMENTAL_MARKING, action.type);
+}
+
+
} // namespace internal
} // namespace v8
Index: test/heap-unittests/heap-unittest.h
diff --git a/test/heap-unittests/heap-unittest.h
b/test/heap-unittests/heap-unittest.h
new file mode 100644
index
0000000000000000000000000000000000000000..ff6f569f1e0050485b8743adff06848d4233c659
--- /dev/null
+++ b/test/heap-unittests/heap-unittest.h
@@ -0,0 +1,41 @@
+// 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.
+
+#ifndef V8_HEAP_UNITTESTS_HEAP_UNITTEST_H_
+#define V8_HEAP_UNITTESTS_HEAP_UNITTEST_H_
+
+#include "src/heap/gc-idle-time-handler.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace v8 {
+namespace internal {
+
+class GCIdleTimeHandlerTest : public ::testing::Test {
+ public:
+ GCIdleTimeHandlerTest() {}
+ virtual ~GCIdleTimeHandlerTest() {}
+
+ GCIdleTimeHandler* handler() { return &handler_; }
+
+ GCIdleTimeHandler::HeapState initial_heap_state() {
+ GCIdleTimeHandler::HeapState result;
+ result.contexts_disposed = 0;
+ result.size_of_objects = kSizeOfObjects;
+ result.incremental_marking_stopped = false;
+ result.can_start_incremental_marking = true;
+ result.mark_compact_speed_in_bytes_per_ms = kMarkCompactSpeed;
+ result.incremental_marking_speed_in_bytes_per_ms = kMarkingSpeed;
+ return result;
+ }
+
+ static const size_t kSizeOfObjects = 100 * MB;
+ static const size_t kMarkCompactSpeed = 100 * KB;
+ static const size_t kMarkingSpeed = 100 * KB;
+
+ private:
+ GCIdleTimeHandler handler_;
+};
+}
+}
+#endif // V8_HEAP_UNITTESTS_HEAP_UNITTEST_H_
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.