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

Side by Side Diff: components/startup_metric_utils/browser/startup_metric_utils.cc

Issue 1620673003: base: Implement GetCurrentThreadPriority. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/startup_metric_utils/browser/startup_metric_utils.h" 5 #include "components/startup_metric_utils/browser/startup_metric_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // compared to multi-seconds startup timings. 231 // compared to multi-seconds startup timings.
232 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) { 232 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) {
233 // First get a base which represents the same point in time in both units. 233 // First get a base which represents the same point in time in both units.
234 // Bump the priority of this thread while doing this as the wall clock time it 234 // Bump the priority of this thread while doing this as the wall clock time it
235 // takes to resolve these two calls affects the precision of this method and 235 // takes to resolve these two calls affects the precision of this method and
236 // bumping the priority reduces the likelihood of a context switch interfering 236 // bumping the priority reduces the likelihood of a context switch interfering
237 // with this computation. 237 // with this computation.
238 238
239 // platform_thread_mac.mm unfortunately doesn't properly support base's 239 // platform_thread_mac.mm unfortunately doesn't properly support base's
240 // thread priority APIs (crbug.com/554651). 240 // thread priority APIs (crbug.com/554651).
241 #if !defined(OS_MACOSX)
242 static bool statics_initialized = false; 241 static bool statics_initialized = false;
243 242
244 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; 243 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL;
245 if (!statics_initialized) { 244 if (!statics_initialized) {
246 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); 245 previous_priority = base::PlatformThread::GetCurrentThreadPriority();
247 base::PlatformThread::SetCurrentThreadPriority( 246 base::PlatformThread::SetCurrentThreadPriority(
248 base::ThreadPriority::DISPLAY); 247 base::ThreadPriority::DISPLAY);
249 } 248 }
250 #endif
251 249
252 static const base::Time time_base = base::Time::Now(); 250 static const base::Time time_base = base::Time::Now();
253 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now(); 251 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now();
254 252
255 #if !defined(OS_MACOSX)
256 if (!statics_initialized) { 253 if (!statics_initialized) {
257 base::PlatformThread::SetCurrentThreadPriority(previous_priority); 254 base::PlatformThread::SetCurrentThreadPriority(previous_priority);
258 } 255 }
259 256
260 statics_initialized = true; 257 statics_initialized = true;
261 #endif
262 258
263 // Then use the TimeDelta common ground between the two units to make the 259 // Then use the TimeDelta common ground between the two units to make the
264 // conversion. 260 // conversion.
265 const base::TimeDelta delta_since_base = time_base - time; 261 const base::TimeDelta delta_since_base = time_base - time;
266 return trace_ticks_base - delta_since_base; 262 return trace_ticks_base - delta_since_base;
267 } 263 }
268 264
269 // Record time of main entry so it can be read from Telemetry performance tests. 265 // Record time of main entry so it can be read from Telemetry performance tests.
270 // TODO(jeremy): Remove once crbug.com/317481 is fixed. 266 // TODO(jeremy): Remove once crbug.com/317481 is fixed.
271 void RecordMainEntryTimeHistogram() { 267 void RecordMainEntryTimeHistogram() {
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 648
653 base::TimeTicks MainEntryPointTicks() { 649 base::TimeTicks MainEntryPointTicks() {
654 return g_browser_main_entry_point_ticks.Get(); 650 return g_browser_main_entry_point_ticks.Get();
655 } 651 }
656 652
657 StartupTemperature GetStartupTemperature() { 653 StartupTemperature GetStartupTemperature() {
658 return g_startup_temperature; 654 return g_startup_temperature;
659 } 655 }
660 656
661 } // namespace startup_metric_utils 657 } // namespace startup_metric_utils
OLDNEW
« base/threading/platform_thread_mac.mm ('K') | « base/threading/platform_thread_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698