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

Unified Diff: test/cctest/test-heap.cc

Issue 1414483004: Add the rate of js invocations from the api as a signal of idleness (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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
« test/cctest/heap-tester.h ('K') | « test/cctest/heap-tester.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-heap.cc
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
index 217ac0123eb3e96040cebb2ebfd358d197922285..4aef03db089f263fff929cac11f7c68258ca1e96 100644
--- a/test/cctest/test-heap.cc
+++ b/test/cctest/test-heap.cc
@@ -35,6 +35,7 @@
#include "src/factory.h"
#include "src/global-handles.h"
#include "src/heap/gc-tracer.h"
+#include "src/heap/memory-reducer.h"
#include "src/ic/ic.h"
#include "src/macro-assembler.h"
#include "src/snapshot/snapshot.h"
@@ -6274,5 +6275,38 @@ TEST(Regress519319) {
}
+// Checks equality for doubles.
+void CheckEquals(double expected, double actual) {
Hannes Payer (out of office) 2015/10/28 14:58:08 Let's move this one to cctest.h since it is a util
ulan 2015/10/29 12:39:25 Done.
+ const double kEpsilon = 1e-10;
+ CHECK_LE(expected, actual + kEpsilon);
+ CHECK_GE(expected, actual - kEpsilon);
+}
+
+
+HEAP_TEST(TestMemoryReducerSampleJsCalls) {
+ CcTest::InitializeVM();
+ v8::HandleScope scope(CcTest::isolate());
+ Heap* heap = CcTest::heap();
+ Isolate* isolate = CcTest::i_isolate();
+ MemoryReducer* memory_reducer = heap->memory_reducer_;
+ memory_reducer->SampleAndGetJsCallsPerMs(0);
+ isolate->IncrementJsCallsFromApiCounter();
+ isolate->IncrementJsCallsFromApiCounter();
+ isolate->IncrementJsCallsFromApiCounter();
+ double calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(1);
+ CheckEquals(3, calls_per_ms);
+
+ calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(2);
+ CheckEquals(0, calls_per_ms);
+
+ isolate->IncrementJsCallsFromApiCounter();
+ isolate->IncrementJsCallsFromApiCounter();
+ isolate->IncrementJsCallsFromApiCounter();
+ isolate->IncrementJsCallsFromApiCounter();
+ calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4);
+ CheckEquals(2, calls_per_ms);
+}
+
+
} // namespace internal
} // namespace v8
« test/cctest/heap-tester.h ('K') | « test/cctest/heap-tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698