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

Side by Side Diff: base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc

Issue 1900223003: [tracing] Ignore tracing allocations in heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes. Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/pending_task.h" 10 #include "base/pending_task.h"
11 #include "base/trace_event/heap_profiler_allocation_context.h" 11 #include "base/trace_event/heap_profiler_allocation_context.h"
12 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 12 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
13 #include "base/trace_event/heap_profiler_scoped_ignore.h"
13 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace base { 17 namespace base {
17 namespace trace_event { 18 namespace trace_event {
18 19
19 // Define all strings once, because the pseudo stack requires pointer equality, 20 // Define all strings once, because the pseudo stack requires pointer equality,
20 // and string interning is unreliable. 21 // and string interning is unreliable.
21 const char kCupcake[] = "Cupcake"; 22 const char kCupcake[] = "Cupcake";
22 const char kDonut[] = "Donut"; 23 const char kDonut[] = "Donut";
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 ASSERT_EQ(kContext2, ctx2.type_name); 272 ASSERT_EQ(kContext2, ctx2.type_name);
272 } 273 }
273 274
274 // Type should be nullptr without task event. 275 // Type should be nullptr without task event.
275 AllocationContext ctx = 276 AllocationContext ctx =
276 AllocationContextTracker::GetInstanceForCurrentThread() 277 AllocationContextTracker::GetInstanceForCurrentThread()
277 ->GetContextSnapshot(); 278 ->GetContextSnapshot();
278 ASSERT_FALSE(ctx.type_name); 279 ASSERT_FALSE(ctx.type_name);
279 } 280 }
280 281
282 TEST_F(AllocationContextTrackerTest, IgnoreAllocationTest) {
283 TRACE_EVENT0("Testing", kCupcake);
284 TRACE_EVENT0("Testing", kDonut);
285 HEAP_PROFILER_SCOPED_IGNORE;
286 AllocationContext ctx1 =
287 AllocationContextTracker::GetInstanceForCurrentThread()
288 ->GetContextSnapshot();
289 const StringPiece kTracingOverhead("tracing_overhead");
290 ASSERT_EQ(kTracingOverhead, ctx1.backtrace.frames[0]);
291 ASSERT_FALSE(ctx1.backtrace.frames[1]);
Primiano Tucci (use gerrit) 2016/04/21 19:47:32 this is not guaranteed to be nullptr anymore. This
ssid 2016/04/22 04:57:12 Done.
292 }
293
281 } // namespace trace_event 294 } // namespace trace_event
282 } // namespace base 295 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698