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

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

Issue 2967023002: android: Add thread time to early TraceEvent, make timings more precise. (Closed)
Patch Set: Comment. Created 3 years, 5 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
« no previous file with comments | « base/trace_event/trace_log.h ('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 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 "base/trace_event/trace_log.h" 5 #include "base/trace_event/trace_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 } 1374 }
1375 1375
1376 void TraceLog::UpdateTraceEventDuration( 1376 void TraceLog::UpdateTraceEventDuration(
1377 const unsigned char* category_group_enabled, 1377 const unsigned char* category_group_enabled,
1378 const char* name, 1378 const char* name,
1379 TraceEventHandle handle) { 1379 TraceEventHandle handle) {
1380 char category_group_enabled_local = *category_group_enabled; 1380 char category_group_enabled_local = *category_group_enabled;
1381 if (!category_group_enabled_local) 1381 if (!category_group_enabled_local)
1382 return; 1382 return;
1383 1383
1384 UpdateTraceEventDurationExplicit(category_group_enabled, name, handle,
1385 OffsetNow(), ThreadNow());
1386 }
1387
1388 void TraceLog::UpdateTraceEventDurationExplicit(
1389 const unsigned char* category_group_enabled,
1390 const char* name,
1391 TraceEventHandle handle,
1392 const TimeTicks& now,
1393 const ThreadTicks& thread_now) {
1394 char category_group_enabled_local = *category_group_enabled;
1395 if (!category_group_enabled_local)
1396 return;
1397
1384 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when 1398 // Avoid re-entrance of AddTraceEvent. This may happen in GPU process when
1385 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) -> 1399 // ECHO_TO_CONSOLE is enabled: AddTraceEvent -> LOG(ERROR) ->
1386 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ... 1400 // GpuProcessLogMessageHandler -> PostPendingTask -> TRACE_EVENT ...
1387 if (thread_is_in_trace_event_.Get()) 1401 if (thread_is_in_trace_event_.Get())
1388 return; 1402 return;
1389
1390 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_); 1403 AutoThreadLocalBoolean thread_is_in_trace_event(&thread_is_in_trace_event_);
1391 1404
1392 ThreadTicks thread_now = ThreadNow();
1393 TimeTicks now = OffsetNow();
1394
1395 #if defined(OS_WIN) 1405 #if defined(OS_WIN)
1396 // Generate an ETW event that marks the end of a complete event. 1406 // Generate an ETW event that marks the end of a complete event.
1397 if (category_group_enabled_local & TraceCategory::ENABLED_FOR_ETW_EXPORT) 1407 if (category_group_enabled_local & TraceCategory::ENABLED_FOR_ETW_EXPORT)
1398 TraceEventETWExport::AddCompleteEndEvent(name); 1408 TraceEventETWExport::AddCompleteEndEvent(name);
1399 #endif // OS_WIN 1409 #endif // OS_WIN
1400 1410
1401 std::string console_message; 1411 std::string console_message;
1402 if (category_group_enabled_local & TraceCategory::ENABLED_FOR_RECORDING) { 1412 if (category_group_enabled_local & TraceCategory::ENABLED_FOR_RECORDING) {
1403 OptionalAutoLock lock(&lock_); 1413 OptionalAutoLock lock(&lock_);
1404 1414
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 } 1712 }
1703 1713
1704 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1714 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1705 if (*category_group_enabled_) { 1715 if (*category_group_enabled_) {
1706 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1716 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1707 event_handle_); 1717 event_handle_);
1708 } 1718 }
1709 } 1719 }
1710 1720
1711 } // namespace trace_event_internal 1721 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/trace_event/trace_log.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698