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

Side by Side Diff: webrtc/base/platform_thread.cc

Issue 2729783004: Add performance tracing for PlatformThread and parts of the video code. (Closed)
Patch Set: Rebase Created 3 years, 9 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 | « no previous file | webrtc/common_video/incoming_video_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/base/platform_thread.h" 11 #include "webrtc/base/platform_thread.h"
12 12
13 #include "webrtc/base/atomicops.h" 13 #include "webrtc/base/atomicops.h"
14 #include "webrtc/base/checks.h" 14 #include "webrtc/base/checks.h"
15 #include "webrtc/base/timeutils.h" 15 #include "webrtc/base/timeutils.h"
16 #include "webrtc/base/trace_event.h"
16 17
17 #if defined(WEBRTC_LINUX) 18 #if defined(WEBRTC_LINUX)
18 #include <sys/prctl.h> 19 #include <sys/prctl.h>
19 #include <sys/syscall.h> 20 #include <sys/syscall.h>
20 #endif 21 #endif
21 22
22 namespace rtc { 23 namespace rtc {
23 24
24 PlatformThreadId CurrentThreadId() { 25 PlatformThreadId CurrentThreadId() {
25 PlatformThreadId ret; 26 PlatformThreadId ret;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // |kMaxLoopCount| controls the limit for how many times we allow the loop 229 // |kMaxLoopCount| controls the limit for how many times we allow the loop
229 // to run within a period, before DCHECKing. 230 // to run within a period, before DCHECKing.
230 // |kPeriodToMeasureMs| controls how long that period is. 231 // |kPeriodToMeasureMs| controls how long that period is.
231 static const int kMaxLoopCount = 1000; 232 static const int kMaxLoopCount = 1000;
232 static const int kPeriodToMeasureMs = 100; 233 static const int kPeriodToMeasureMs = 100;
233 int64_t loop_stamps[kMaxLoopCount] = {}; 234 int64_t loop_stamps[kMaxLoopCount] = {};
234 int64_t sequence_nr = 0; 235 int64_t sequence_nr = 0;
235 #endif 236 #endif
236 237
237 do { 238 do {
239 TRACE_EVENT1("webrtc", "PlatformThread::Run", "name", name_.c_str());
240
238 // The interface contract of Start/Stop is that for a successful call to 241 // The interface contract of Start/Stop is that for a successful call to
239 // Start, there should be at least one call to the run function. So we 242 // Start, there should be at least one call to the run function. So we
240 // call the function before checking |stop_|. 243 // call the function before checking |stop_|.
241 if (!run_function_deprecated_(obj_)) 244 if (!run_function_deprecated_(obj_))
242 break; 245 break;
243 #if RTC_DCHECK_IS_ON 246 #if RTC_DCHECK_IS_ON
244 auto id = sequence_nr % kMaxLoopCount; 247 auto id = sequence_nr % kMaxLoopCount;
245 loop_stamps[id] = rtc::TimeMillis(); 248 loop_stamps[id] = rtc::TimeMillis();
246 if (sequence_nr > kMaxLoopCount) { 249 if (sequence_nr > kMaxLoopCount) {
247 auto compare_id = (id + 1) % kMaxLoopCount; 250 auto compare_id = (id + 1) % kMaxLoopCount;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 #if defined(WEBRTC_WIN) 342 #if defined(WEBRTC_WIN)
340 bool PlatformThread::QueueAPC(PAPCFUNC function, ULONG_PTR data) { 343 bool PlatformThread::QueueAPC(PAPCFUNC function, ULONG_PTR data) {
341 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 344 RTC_DCHECK(thread_checker_.CalledOnValidThread());
342 RTC_DCHECK(IsRunning()); 345 RTC_DCHECK(IsRunning());
343 346
344 return QueueUserAPC(function, thread_, data) != FALSE; 347 return QueueUserAPC(function, thread_, data) != FALSE;
345 } 348 }
346 #endif 349 #endif
347 350
348 } // namespace rtc 351 } // namespace rtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/common_video/incoming_video_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698