OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 17 matching lines...) Expand all Loading... | |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 #include <utility> | 29 #include <utility> |
30 | 30 |
31 #include "src/compilation-cache.h" | 31 #include "src/compilation-cache.h" |
32 #include "src/context-measure.h" | 32 #include "src/context-measure.h" |
33 #include "src/deoptimizer.h" | 33 #include "src/deoptimizer.h" |
34 #include "src/execution.h" | 34 #include "src/execution.h" |
35 #include "src/factory.h" | 35 #include "src/factory.h" |
36 #include "src/global-handles.h" | 36 #include "src/global-handles.h" |
37 #include "src/heap/gc-tracer.h" | 37 #include "src/heap/gc-tracer.h" |
38 #include "src/heap/memory-reducer.h" | |
38 #include "src/ic/ic.h" | 39 #include "src/ic/ic.h" |
39 #include "src/macro-assembler.h" | 40 #include "src/macro-assembler.h" |
40 #include "src/snapshot/snapshot.h" | 41 #include "src/snapshot/snapshot.h" |
41 #include "test/cctest/cctest.h" | 42 #include "test/cctest/cctest.h" |
42 #include "test/cctest/heap-tester.h" | 43 #include "test/cctest/heap-tester.h" |
43 #include "test/cctest/test-feedback-vector.h" | 44 #include "test/cctest/test-feedback-vector.h" |
44 | 45 |
45 using v8::Just; | 46 using v8::Just; |
46 | 47 |
47 namespace v8 { | 48 namespace v8 { |
(...skipping 6219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6267 isolate->SetReferenceFromGroup(id, child); | 6268 isolate->SetReferenceFromGroup(id, child); |
6268 } | 6269 } |
6269 // The CollectGarbage call above starts sweeper threads. | 6270 // The CollectGarbage call above starts sweeper threads. |
6270 // The crash will happen if the following two functions | 6271 // The crash will happen if the following two functions |
6271 // are called before sweeping finishes. | 6272 // are called before sweeping finishes. |
6272 heap->StartIncrementalMarking(); | 6273 heap->StartIncrementalMarking(); |
6273 heap->FinalizeIncrementalMarkingIfComplete("test"); | 6274 heap->FinalizeIncrementalMarkingIfComplete("test"); |
6274 } | 6275 } |
6275 | 6276 |
6276 | 6277 |
6278 // Checks equality for doubles. | |
6279 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.
| |
6280 const double kEpsilon = 1e-10; | |
6281 CHECK_LE(expected, actual + kEpsilon); | |
6282 CHECK_GE(expected, actual - kEpsilon); | |
6283 } | |
6284 | |
6285 | |
6286 HEAP_TEST(TestMemoryReducerSampleJsCalls) { | |
6287 CcTest::InitializeVM(); | |
6288 v8::HandleScope scope(CcTest::isolate()); | |
6289 Heap* heap = CcTest::heap(); | |
6290 Isolate* isolate = CcTest::i_isolate(); | |
6291 MemoryReducer* memory_reducer = heap->memory_reducer_; | |
6292 memory_reducer->SampleAndGetJsCallsPerMs(0); | |
6293 isolate->IncrementJsCallsFromApiCounter(); | |
6294 isolate->IncrementJsCallsFromApiCounter(); | |
6295 isolate->IncrementJsCallsFromApiCounter(); | |
6296 double calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(1); | |
6297 CheckEquals(3, calls_per_ms); | |
6298 | |
6299 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(2); | |
6300 CheckEquals(0, calls_per_ms); | |
6301 | |
6302 isolate->IncrementJsCallsFromApiCounter(); | |
6303 isolate->IncrementJsCallsFromApiCounter(); | |
6304 isolate->IncrementJsCallsFromApiCounter(); | |
6305 isolate->IncrementJsCallsFromApiCounter(); | |
6306 calls_per_ms = memory_reducer->SampleAndGetJsCallsPerMs(4); | |
6307 CheckEquals(2, calls_per_ms); | |
6308 } | |
6309 | |
6310 | |
6277 } // namespace internal | 6311 } // namespace internal |
6278 } // namespace v8 | 6312 } // namespace v8 |
OLD | NEW |