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

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

Issue 1838173003: Revert changes to startup_metric_utils.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | 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 "base/containers/hash_tables.h" 9 #include "base/containers/hash_tables.h"
10 #include "base/environment.h" 10 #include "base/environment.h"
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // base::TimeTicks::Now() at play, but in practice it is pretty much instant 263 // base::TimeTicks::Now() at play, but in practice it is pretty much instant
264 // compared to multi-seconds startup timings. 264 // compared to multi-seconds startup timings.
265 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) { 265 base::TimeTicks StartupTimeToTimeTicks(const base::Time& time) {
266 // First get a base which represents the same point in time in both units. 266 // First get a base which represents the same point in time in both units.
267 // Bump the priority of this thread while doing this as the wall clock time it 267 // Bump the priority of this thread while doing this as the wall clock time it
268 // takes to resolve these two calls affects the precision of this method and 268 // takes to resolve these two calls affects the precision of this method and
269 // bumping the priority reduces the likelihood of a context switch interfering 269 // bumping the priority reduces the likelihood of a context switch interfering
270 // with this computation. 270 // with this computation.
271 271
272 // platform_thread_mac.mm unfortunately doesn't properly support base's 272 // platform_thread_mac.mm unfortunately doesn't properly support base's
273 // thread priority APIs (crbug.com/554651). 273 // thread priority APIs (crbug.com/554651).
gab 2016/04/07 00:56:32 Please update this comment.
274 #if !defined(OS_MACOSX)
274 static bool statics_initialized = false; 275 static bool statics_initialized = false;
275 276
276 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL; 277 base::ThreadPriority previous_priority = base::ThreadPriority::NORMAL;
277 if (!statics_initialized) { 278 if (!statics_initialized) {
278 previous_priority = base::PlatformThread::GetCurrentThreadPriority(); 279 previous_priority = base::PlatformThread::GetCurrentThreadPriority();
279 base::PlatformThread::SetCurrentThreadPriority( 280 base::PlatformThread::SetCurrentThreadPriority(
280 base::ThreadPriority::DISPLAY); 281 base::ThreadPriority::DISPLAY);
281 } 282 }
283 #endif
282 284
283 static const base::Time time_base = base::Time::Now(); 285 static const base::Time time_base = base::Time::Now();
284 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now(); 286 static const base::TimeTicks trace_ticks_base = base::TimeTicks::Now();
285 287
288 #if !defined(OS_MACOSX)
286 if (!statics_initialized) { 289 if (!statics_initialized) {
287 base::PlatformThread::SetCurrentThreadPriority(previous_priority); 290 base::PlatformThread::SetCurrentThreadPriority(previous_priority);
288 } 291 }
289
290 statics_initialized = true; 292 statics_initialized = true;
293 #endif
291 294
292 // Then use the TimeDelta common ground between the two units to make the 295 // Then use the TimeDelta common ground between the two units to make the
293 // conversion. 296 // conversion.
294 const base::TimeDelta delta_since_base = time_base - time; 297 const base::TimeDelta delta_since_base = time_base - time;
295 return trace_ticks_base - delta_since_base; 298 return trace_ticks_base - delta_since_base;
296 } 299 }
297 300
298 // Record time of main entry so it can be read from Telemetry performance tests. 301 // Record time of main entry so it can be read from Telemetry performance tests.
299 // TODO(jeremy): Remove once crbug.com/317481 is fixed. 302 // TODO(jeremy): Remove once crbug.com/317481 is fixed.
300 void RecordMainEntryTimeHistogram() { 303 void RecordMainEntryTimeHistogram() {
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 702
700 base::TimeTicks MainEntryPointTicks() { 703 base::TimeTicks MainEntryPointTicks() {
701 return g_browser_main_entry_point_ticks.Get(); 704 return g_browser_main_entry_point_ticks.Get();
702 } 705 }
703 706
704 StartupTemperature GetStartupTemperature() { 707 StartupTemperature GetStartupTemperature() {
705 return g_startup_temperature; 708 return g_startup_temperature;
706 } 709 }
707 710
708 } // namespace startup_metric_utils 711 } // namespace startup_metric_utils
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698