Index: test/cctest/test-heap.cc |
diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
index 217ac0123eb3e96040cebb2ebfd358d197922285..cc384d353e9379a5aa7d5c555da67d22b43cf29b 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,30 @@ TEST(Regress519319) { |
} |
+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); |
+ CheckDoubleEquals(3, calls_per_ms); |
+ |
+ calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(2); |
+ CheckDoubleEquals(0, calls_per_ms); |
+ |
+ isolate->IncrementJsCallsFromApiCounter(); |
+ isolate->IncrementJsCallsFromApiCounter(); |
+ isolate->IncrementJsCallsFromApiCounter(); |
+ isolate->IncrementJsCallsFromApiCounter(); |
+ calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); |
+ CheckDoubleEquals(2, calls_per_ms); |
+} |
+ |
+ |
} // namespace internal |
} // namespace v8 |