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

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

Issue 2700033003: Disabled MallocHooks code in Release due to performance concerns. Added enable_malloc_hooks flag to… (Closed)
Patch Set: Created 3 years, 10 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
« runtime/vm/malloc_hooks.cc ('K') | « runtime/vm/malloc_hooks.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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/globals.h" 5 #include "platform/globals.h"
6 6
7 #if defined(DART_USE_TCMALLOC) && !defined(PRODUCT) 7 #if defined(DART_USE_TCMALLOC) && defined(DEBUG)
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
11 #include "vm/globals.h" 11 #include "vm/globals.h"
12 #include "vm/malloc_hooks.h" 12 #include "vm/malloc_hooks.h"
13 #include "vm/symbols.h" 13 #include "vm/symbols.h"
14 #include "vm/unit_test.h" 14 #include "vm/unit_test.h"
15 15
16 namespace dart { 16 namespace dart {
17 17
18 static void MallocHookTestBufferInitializer(volatile char* buffer, 18 static void MallocHookTestBufferInitializer(volatile char* buffer,
19 uintptr_t size) { 19 uintptr_t size) {
20 // Run through the buffer and do something. If we don't do this and the memory 20 // Run through the buffer and do something. If we don't do this and the memory
21 // in buffer isn't touched, the tcmalloc hooks won't be called. 21 // in buffer isn't touched, the tcmalloc hooks won't be called.
22 for (uintptr_t i = 0; i < size; ++i) { 22 for (uintptr_t i = 0; i < size; ++i) {
23 buffer[i] = i; 23 buffer[i] = i;
24 } 24 }
25 } 25 }
26 26
27 27
28 UNIT_TEST_CASE(BasicMallocHookTest) { 28 UNIT_TEST_CASE(BasicMallocHookTest) {
rmacnak 2017/02/17 23:39:22 If it's available in release mode, it should be te
zra 2017/02/17 23:43:27 +1
29 MallocHooks::InitOnce(); 29 MallocHooks::InitOnce();
30 MallocHooks::ResetStats(); 30 MallocHooks::ResetStats();
31 EXPECT_EQ(0L, MallocHooks::allocation_count()); 31 EXPECT_EQ(0L, MallocHooks::allocation_count());
32 EXPECT_EQ(0L, MallocHooks::heap_allocated_memory_in_bytes()); 32 EXPECT_EQ(0L, MallocHooks::heap_allocated_memory_in_bytes());
33 const intptr_t buffer_size = 10; 33 const intptr_t buffer_size = 10;
34 char* buffer = new char[buffer_size]; 34 char* buffer = new char[buffer_size];
35 MallocHookTestBufferInitializer(buffer, buffer_size); 35 MallocHookTestBufferInitializer(buffer, buffer_size);
36 36
37 EXPECT_EQ(1L, MallocHooks::allocation_count()); 37 EXPECT_EQ(1L, MallocHooks::allocation_count());
38 EXPECT_EQ(static_cast<intptr_t>(sizeof(char) * buffer_size), 38 EXPECT_EQ(static_cast<intptr_t>(sizeof(char) * buffer_size),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 71
72 delete[] buffer; 72 delete[] buffer;
73 EXPECT_EQ(0L, MallocHooks::allocation_count()); 73 EXPECT_EQ(0L, MallocHooks::allocation_count());
74 EXPECT_EQ(0L, MallocHooks::heap_allocated_memory_in_bytes()); 74 EXPECT_EQ(0L, MallocHooks::heap_allocated_memory_in_bytes());
75 MallocHooks::TearDown(); 75 MallocHooks::TearDown();
76 } 76 }
77 77
78 }; // namespace dart 78 }; // namespace dart
79 79
80 #endif // defined(DART_USE_TCMALLOC) && !defined(PRODUCT) 80 #endif // defined(DART_USE_TCMALLOC) && defined(DEBUG)
OLDNEW
« runtime/vm/malloc_hooks.cc ('K') | « runtime/vm/malloc_hooks.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698