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

Side by Side Diff: runtime/vm/profiler_test.cc

Issue 2829833003: [Fuchsia] Grab the number of malloc'd bytes from jemalloc (Closed)
Patch Set: Fix guards Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "platform/assert.h" 5 #include "platform/assert.h"
6 6
7 #include "vm/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/profiler.h" 10 #include "vm/profiler.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 #if defined(DART_USE_TCMALLOC) && defined(HOST_OS_LINUX) && defined(DEBUG) && \ 319 #if defined(DART_USE_TCMALLOC) && defined(HOST_OS_LINUX) && defined(DEBUG) && \
320 defined(HOST_ARCH_x64) 320 defined(HOST_ARCH_x64)
321 321
322 DART_NOINLINE static void NativeAllocationSampleHelper(char** result) { 322 DART_NOINLINE static void NativeAllocationSampleHelper(char** result) {
323 ASSERT(result != NULL); 323 ASSERT(result != NULL);
324 *result = static_cast<char*>(malloc(sizeof(char) * 1024)); 324 *result = static_cast<char*>(malloc(sizeof(char) * 1024));
325 } 325 }
326 326
327 327
328 ISOLATE_UNIT_TEST_CASE(Profiler_NativeAllocation) { 328 ISOLATE_UNIT_TEST_CASE(Profiler_NativeAllocation) {
329 bool enable_malloc_hooks_saved = FLAG_enable_malloc_hooks; 329 bool enable_malloc_hooks_saved = FLAG_profiler_native_memory;
330 FLAG_enable_malloc_hooks = true; 330 FLAG_profiler_native_memory = true;
331 331
332 MallocHooks::InitOnce(); 332 MallocHooks::InitOnce();
333 MallocHooks::ResetStats(); 333 MallocHooks::ResetStats();
334 bool stack_trace_collection_enabled = 334 bool stack_trace_collection_enabled =
335 MallocHooks::stack_trace_collection_enabled(); 335 MallocHooks::stack_trace_collection_enabled();
336 MallocHooks::set_stack_trace_collection_enabled(true); 336 MallocHooks::set_stack_trace_collection_enabled(true);
337 337
338 char* result = NULL; 338 char* result = NULL;
339 const int64_t before_allocations_micros = Dart_TimelineGetMicros(); 339 const int64_t before_allocations_micros = Dart_TimelineGetMicros();
340 NativeAllocationSampleHelper(&result); 340 NativeAllocationSampleHelper(&result);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 NativeAllocationSampleFilter filter(Dart_TimelineGetMicros(), 16000); 515 NativeAllocationSampleFilter filter(Dart_TimelineGetMicros(), 16000);
516 profile.Build(thread, &filter, Profile::kNoTags); 516 profile.Build(thread, &filter, Profile::kNoTags);
517 // We should have no allocation samples because none occured within 517 // We should have no allocation samples because none occured within
518 // the specified time range. 518 // the specified time range.
519 EXPECT_EQ(0, profile.sample_count()); 519 EXPECT_EQ(0, profile.sample_count());
520 } 520 }
521 521
522 MallocHooks::set_stack_trace_collection_enabled( 522 MallocHooks::set_stack_trace_collection_enabled(
523 stack_trace_collection_enabled); 523 stack_trace_collection_enabled);
524 MallocHooks::TearDown(); 524 MallocHooks::TearDown();
525 FLAG_enable_malloc_hooks = enable_malloc_hooks_saved; 525 FLAG_profiler_native_memory = enable_malloc_hooks_saved;
526 } 526 }
527 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) && 527 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) &&
528 // !defined(TARGET_ARCH_DBC) && !defined(HOST_OS_FUCHSIA) 528 // !defined(TARGET_ARCH_DBC) && !defined(HOST_OS_FUCHSIA)
529 529
530 530
531 TEST_CASE(Profiler_ToggleRecordAllocation) { 531 TEST_CASE(Profiler_ToggleRecordAllocation) {
532 DisableNativeProfileScope dnps; 532 DisableNativeProfileScope dnps;
533 const char* kScript = 533 const char* kScript =
534 "class A {\n" 534 "class A {\n"
535 " var a;\n" 535 " var a;\n"
(...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString()); 2805 EXPECT_SUBSTRING("\"positions\":[\"TempMove\",39]", js.ToCString());
2806 // Verify exclusive ticks in main. 2806 // Verify exclusive ticks in main.
2807 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString()); 2807 EXPECT_SUBSTRING("\"exclusiveTicks\":[1,0]", js.ToCString());
2808 // Verify inclusive ticks in main. 2808 // Verify inclusive ticks in main.
2809 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString()); 2809 EXPECT_SUBSTRING("\"inclusiveTicks\":[1,2]", js.ToCString());
2810 } 2810 }
2811 2811
2812 #endif // !PRODUCT 2812 #endif // !PRODUCT
2813 2813
2814 } // namespace dart 2814 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698