OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/profiler_service.h" | 5 #include "vm/profiler_service.h" |
6 | 6 |
7 #include "vm/growable_array.h" | 7 #include "vm/growable_array.h" |
8 #include "vm/log.h" | 8 #include "vm/log.h" |
9 #include "vm/native_symbol.h" | 9 #include "vm/native_symbol.h" |
10 #include "vm/object.h" | 10 #include "vm/object.h" |
(...skipping 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 } else { | 2490 } else { |
2491 profile.PrintProfileJSON(stream); | 2491 profile.PrintProfileJSON(stream); |
2492 } | 2492 } |
2493 } | 2493 } |
2494 } | 2494 } |
2495 | 2495 |
2496 | 2496 |
2497 class NoAllocationSampleFilter : public SampleFilter { | 2497 class NoAllocationSampleFilter : public SampleFilter { |
2498 public: | 2498 public: |
2499 NoAllocationSampleFilter(Isolate* isolate, | 2499 NoAllocationSampleFilter(Isolate* isolate, |
| 2500 bool include_background_samples, |
2500 int64_t time_origin_micros, | 2501 int64_t time_origin_micros, |
2501 int64_t time_extent_micros) | 2502 int64_t time_extent_micros) |
2502 : SampleFilter(isolate, | 2503 : SampleFilter(isolate, |
2503 time_origin_micros, | 2504 time_origin_micros, |
2504 time_extent_micros) { | 2505 time_extent_micros), |
| 2506 include_background_samples_(include_background_samples) { |
2505 } | 2507 } |
2506 | 2508 |
2507 bool FilterSample(Sample* sample) { | 2509 bool FilterSample(Sample* sample) { |
2508 return !sample->is_allocation_sample(); | 2510 if (sample->is_allocation_sample()) { |
| 2511 return false; |
| 2512 } |
| 2513 return sample->is_mutator_thread() || include_background_samples_; |
2509 } | 2514 } |
| 2515 |
| 2516 private: |
| 2517 const bool include_background_samples_; |
2510 }; | 2518 }; |
2511 | 2519 |
2512 | 2520 |
2513 void ProfilerService::PrintJSON(JSONStream* stream, | 2521 void ProfilerService::PrintJSON(JSONStream* stream, |
2514 Profile::TagOrder tag_order, | 2522 Profile::TagOrder tag_order, |
2515 intptr_t extra_tags, | 2523 intptr_t extra_tags, |
2516 int64_t time_origin_micros, | 2524 int64_t time_origin_micros, |
2517 int64_t time_extent_micros) { | 2525 int64_t time_extent_micros) { |
2518 Thread* thread = Thread::Current(); | 2526 Thread* thread = Thread::Current(); |
2519 Isolate* isolate = thread->isolate(); | 2527 Isolate* isolate = thread->isolate(); |
| 2528 const bool include_background_samples = false; |
2520 NoAllocationSampleFilter filter(isolate, | 2529 NoAllocationSampleFilter filter(isolate, |
| 2530 include_background_samples, |
2521 time_origin_micros, | 2531 time_origin_micros, |
2522 time_extent_micros); | 2532 time_extent_micros); |
2523 const bool as_timeline = false; | 2533 const bool as_timeline = false; |
2524 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline); | 2534 PrintJSONImpl(thread, stream, tag_order, extra_tags, &filter, as_timeline); |
2525 } | 2535 } |
2526 | 2536 |
2527 | 2537 |
2528 class ClassAllocationSampleFilter : public SampleFilter { | 2538 class ClassAllocationSampleFilter : public SampleFilter { |
2529 public: | 2539 public: |
2530 ClassAllocationSampleFilter(Isolate* isolate, | 2540 ClassAllocationSampleFilter(Isolate* isolate, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2563 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); | 2573 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); |
2564 } | 2574 } |
2565 | 2575 |
2566 | 2576 |
2567 void ProfilerService::PrintTimelineJSON(JSONStream* stream, | 2577 void ProfilerService::PrintTimelineJSON(JSONStream* stream, |
2568 Profile::TagOrder tag_order, | 2578 Profile::TagOrder tag_order, |
2569 int64_t time_origin_micros, | 2579 int64_t time_origin_micros, |
2570 int64_t time_extent_micros) { | 2580 int64_t time_extent_micros) { |
2571 Thread* thread = Thread::Current(); | 2581 Thread* thread = Thread::Current(); |
2572 Isolate* isolate = thread->isolate(); | 2582 Isolate* isolate = thread->isolate(); |
| 2583 const bool include_background_samples = true; |
2573 NoAllocationSampleFilter filter(isolate, | 2584 NoAllocationSampleFilter filter(isolate, |
| 2585 include_background_samples, |
2574 time_origin_micros, | 2586 time_origin_micros, |
2575 time_extent_micros); | 2587 time_extent_micros); |
2576 const bool as_timeline = true; | 2588 const bool as_timeline = true; |
2577 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); | 2589 PrintJSONImpl(thread, stream, tag_order, kNoExtraTags, &filter, as_timeline); |
2578 } | 2590 } |
2579 | 2591 |
2580 | 2592 |
2581 void ProfilerService::ClearSamples() { | 2593 void ProfilerService::ClearSamples() { |
2582 SampleBuffer* sample_buffer = Profiler::sample_buffer(); | 2594 SampleBuffer* sample_buffer = Profiler::sample_buffer(); |
2583 if (sample_buffer == NULL) { | 2595 if (sample_buffer == NULL) { |
2584 return; | 2596 return; |
2585 } | 2597 } |
2586 | 2598 |
2587 Thread* thread = Thread::Current(); | 2599 Thread* thread = Thread::Current(); |
2588 Isolate* isolate = thread->isolate(); | 2600 Isolate* isolate = thread->isolate(); |
2589 | 2601 |
2590 // Disable thread interrupts while processing the buffer. | 2602 // Disable thread interrupts while processing the buffer. |
2591 DisableThreadInterruptsScope dtis(thread); | 2603 DisableThreadInterruptsScope dtis(thread); |
2592 | 2604 |
2593 ClearProfileVisitor clear_profile(isolate); | 2605 ClearProfileVisitor clear_profile(isolate); |
2594 sample_buffer->VisitSamples(&clear_profile); | 2606 sample_buffer->VisitSamples(&clear_profile); |
2595 } | 2607 } |
2596 | 2608 |
2597 #endif // !PRODUCT | 2609 #endif // !PRODUCT |
2598 | 2610 |
2599 } // namespace dart | 2611 } // namespace dart |
OLD | NEW |