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

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

Issue 2221083002: Revert of Reland #1: "base: Implement GetCurrentThreadPriority." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/threading/platform_thread_unittest.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 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 <memory> 9 #include <memory>
10 10
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // also the time taken to synchronously resolve base::Time::Now() and 309 // also the time taken to synchronously resolve base::Time::Now() and
310 // base::TimeTicks::Now() at play, but in practice it is pretty much instant 310 // base::TimeTicks::Now() at play, but in practice it is pretty much instant
311 // compared to multi-seconds startup timings. 311 // compared to multi-seconds startup timings.
312 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) { 312 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) {
313 // First get a base which represents the same point in time in both units. 313 // First get a base which represents the same point in time in both units.
314 // Bump the priority of this thread while doing this as the wall clock time it 314 // Bump the priority of this thread while doing this as the wall clock time it
315 // takes to resolve these two calls affects the precision of this method and 315 // takes to resolve these two calls affects the precision of this method and
316 // bumping the priority reduces the likelihood of a context switch interfering 316 // bumping the priority reduces the likelihood of a context switch interfering
317 // with this computation. 317 // with this computation.
318 318
319 // Enabling this logic on OS X causes a significant performance regression.
320 // https://crbug.com/601270
321 #if !defined(OS_MACOSX)
319 static bool statics_initialized = false; 322 static bool statics_initialized = false;
320 323
321 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; 324 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL;
322 if (!statics_initialized) { 325 if (!statics_initialized) {
323 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); 326 previous_priority = base::PlatformThread::GetCurrentThreadPriority();
324 base::PlatformThread::SetCurrentThreadPriority( 327 base::PlatformThread::SetCurrentThreadPriority(
325 base::ThreadPriority::DISPLAY); 328 base::ThreadPriority::DISPLAY);
326 } 329 }
330 #endif
327 331
328 static const base::Time time_base = base::Time::Now(); 332 static const base::Time time_base = base::Time::Now();
329 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now(); 333 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now();
330 334
335 #if !defined(OS_MACOSX)
331 if (!statics_initialized) { 336 if (!statics_initialized) {
332 base::PlatformThread::SetCurrentThreadPriority(previous_priority); 337 base::PlatformThread::SetCurrentThreadPriority(previous_priority);
333 } 338 }
334 statics_initialized = true; 339 statics_initialized = true;
340 #endif
335 341
336 // Then use the TimeDelta common ground between the two units to make the 342 // Then use the TimeDelta common ground between the two units to make the
337 // conversion. 343 // conversion.
338 const base::TimeDelta delta_since_base = time_base - time; 344 const base::TimeDelta delta_since_base = time_base - time;
339 return trace_ticks_base - delta_since_base; 345 return trace_ticks_base - delta_since_base;
340 } 346 }
341 347
342 // Record time of main entry so it can be read from Telemetry performance tests. 348 // Record time of main entry so it can be read from Telemetry performance tests.
343 // TODO(jeremy): Remove once crbug.com/317481 is fixed. 349 // TODO(jeremy): Remove once crbug.com/317481 is fixed.
344 void RecordMainEntryTimeHistogram() { 350 void RecordMainEntryTimeHistogram() {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 747
742 base::TimeTicks MainEntryPointTicks() { 748 base::TimeTicks MainEntryPointTicks() {
743 return g_browser_main_entry_point_ticks.Get(); 749 return g_browser_main_entry_point_ticks.Get();
744 } 750 }
745 751
746 StartupTemperature GetStartupTemperature() { 752 StartupTemperature GetStartupTemperature() {
747 return g_startup_temperature; 753 return g_startup_temperature;
748 } 754 }
749 755
750 } // namespace startup_metric_utils 756 } // namespace startup_metric_utils
OLDNEW
« no previous file with comments | « base/threading/platform_thread_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698