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

Unified Diff: extensions/common/extension.cc

Issue 2607773003: [Extensions] Add metrics for extension initialization (Closed)
Patch Set: suffixes Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/extension.cc
diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc
index 2f5e2d653e2996f575147f8c36d8358da6965c12..9b46a92c976f67d51d736c3bbe8686236187e267 100644
--- a/extensions/common/extension.cc
+++ b/extensions/common/extension.cc
@@ -15,6 +15,7 @@
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
+#include "base/metrics/histogram_macros.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
@@ -22,9 +23,11 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/timer/elapsed_timer.h"
#include "base/values.h"
#include "base/version.h"
#include "components/crx_file/id_util.h"
+#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
@@ -116,6 +119,7 @@ scoped_refptr<Extension> Extension::Create(const base::FilePath& path,
int flags,
const std::string& explicit_id,
std::string* utf8_error) {
+ base::ElapsedTimer timer;
DCHECK(utf8_error);
base::string16 error;
std::unique_ptr<extensions::Manifest> manifest(new extensions::Manifest(
@@ -139,6 +143,27 @@ scoped_refptr<Extension> Extension::Create(const base::FilePath& path,
return NULL;
}
+ const base::CommandLine& command_line =
+ *base::CommandLine::ForCurrentProcess();
+ std::string process_type =
+ command_line.GetSwitchValueASCII(::switches::kProcessType);
+ // Use microsecond accuracy for increased granularity. Max at 10 seconds.
+ base::TimeDelta elapsed_time = timer.Elapsed();
+ const int kMaxTimeInMicroseconds = 10000000;
+ if (process_type.empty()) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ "Extensions.ExtensionCreationTime.BrowserProcess",
+ elapsed_time.InMicroseconds(), 1, kMaxTimeInMicroseconds, 100);
+ } else if (command_line.HasSwitch(switches::kExtensionProcess)) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ "Extensions.ExtensionCreationTime.ExtensionProcess",
+ elapsed_time.InMicroseconds(), 1, kMaxTimeInMicroseconds, 100);
+ } else if (process_type == ::switches::kRendererProcess) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS(
+ "Extensions.ExtensionCreationTime.RendererProcess",
+ elapsed_time.InMicroseconds(), 1, kMaxTimeInMicroseconds, 100);
+ }
+
return extension;
}
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698