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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 11785014: Record metrics for slow startups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chrome_browser_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 // Windows. 1609 // Windows.
1610 #if defined(OS_MACOSX) || defined(OS_WIN) 1610 #if defined(OS_MACOSX) || defined(OS_WIN)
1611 const base::Time *process_creation_time = 1611 const base::Time *process_creation_time =
1612 base::CurrentProcessInfo::CreationTime(); 1612 base::CurrentProcessInfo::CreationTime();
1613 1613
1614 if (process_creation_time) 1614 if (process_creation_time)
1615 RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime", 1615 RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime",
1616 base::Time::Now() - *process_creation_time); 1616 base::Time::Now() - *process_creation_time);
1617 #endif // OS_MACOSX || OS_WIN 1617 #endif // OS_MACOSX || OS_WIN
1618 1618
1619 // Startup.BrowserMessageLoopStartTime exhibits instability in the field 1619 // Record collected startup metrics.
1620 // which limits its usefullness in all scenarios except when we have a very 1620 startup_metric_utils::OnBrowserStartupComplete();
1621 // large sample size.
1622 // Attempt to mitigate this with a new metric:
1623 // * Measure time from main entry rather than the OS' notion of process start
1624 // time.
1625 // * Only measure launches that occur 7 minutes after boot to try to avoid
1626 // cases where Chrome is auto-started and IO is heavily loaded.
1627 const int64 kSevenMinutesInMilliseconds =
1628 base::TimeDelta::FromMinutes(7).InMilliseconds();
1629 if (base::SysInfo::Uptime() < kSevenMinutesInMilliseconds)
1630 return;
1631
1632 // Set up to match Startup.BrowserMessageLoopStartTime measurement above.
1633 const base::TimeDelta kStartupTimeMin(base::TimeDelta::FromMilliseconds(1));
1634 const base::TimeDelta kStartupTimeMax(base::TimeDelta::FromHours(1));
1635 static const size_t kStartupTimeBuckets(100);
1636 HISTOGRAM_CUSTOM_TIMES(
1637 "Startup.BrowserMessageLoopStartTimeFromMainEntry",
1638 base::Time::Now() - startup_metric_utils::MainEntryStartTime(),
1639 kStartupTimeMin,
1640 kStartupTimeMax,
1641 kStartupTimeBuckets);
1642 } 1621 }
1643 1622
1644 // This code is specific to the Windows-only PreReadExperiment field-trial. 1623 // This code is specific to the Windows-only PreReadExperiment field-trial.
1645 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { 1624 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) {
1646 DCHECK(name != NULL); 1625 DCHECK(name != NULL);
1647 1626
1648 // This gets called with different histogram names, so we don't want to use 1627 // This gets called with different histogram names, so we don't want to use
1649 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the 1628 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the
1650 // first call wins. 1629 // first call wins.
1651 AddPreReadHistogramTime(name, time); 1630 AddPreReadHistogramTime(name, time);
(...skipping 14 matching lines...) Expand all
1666 if (base::win::GetVersion() <= base::win::VERSION_XP) 1645 if (base::win::GetVersion() <= base::win::VERSION_XP)
1667 uma_name += "_XP"; 1646 uma_name += "_XP";
1668 1647
1669 uma_name += "_PreRead_"; 1648 uma_name += "_PreRead_";
1670 uma_name += pre_read_percentage; 1649 uma_name += pre_read_percentage;
1671 AddPreReadHistogramTime(uma_name.c_str(), time); 1650 AddPreReadHistogramTime(uma_name.c_str(), time);
1672 } 1651 }
1673 #endif 1652 #endif
1674 #endif 1653 #endif
1675 } 1654 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698