From fca0f4dc562018d756a160d40aff6eda9629fdfb Mon Sep 17 00:00:00 2001 From: rkaplow Date: Sat, 14 Mar 2015 14:40:57 -0700 Subject: Add metric measuring Feature Provider Static() length in the browser process. We are investigating the cost of ExtensionService::Init(), and want to see the effect of this static initialization, specifically in the browser process which affects startup. BUG=454789 Review URL: https://codereview.chromium.org/996013004 Cr-Commit-Position: refs/heads/master@{#320668} --- extensions/common/features/feature_provider.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'extensions/common/features') diff --git a/extensions/common/features/feature_provider.cc b/extensions/common/features/feature_provider.cc index 90e7924..b7f6f48 100644 --- a/extensions/common/features/feature_provider.cc +++ b/extensions/common/features/feature_provider.cc @@ -7,9 +7,14 @@ #include #include "base/basictypes.h" +#include "base/command_line.h" #include "base/lazy_instance.h" #include "base/memory/linked_ptr.h" +#include "base/metrics/histogram_macros.h" +#include "base/trace_event/trace_event.h" +#include "content/public/common/content_switches.h" #include "extensions/common/extensions_client.h" +#include "extensions/common/switches.h" namespace extensions { @@ -27,6 +32,9 @@ class Static { friend struct base::DefaultLazyInstanceTraits; Static() { + TRACE_EVENT0("startup", "extensions::FeatureProvider::Static"); + base::Time begin_time = base::Time::Now(); + ExtensionsClient* client = ExtensionsClient::Get(); feature_providers_["api"] = make_linked_ptr(client->CreateFeatureProvider("api").release()); @@ -36,6 +44,20 @@ class Static { make_linked_ptr(client->CreateFeatureProvider("permission").release()); feature_providers_["behavior"] = make_linked_ptr(client->CreateFeatureProvider("behavior").release()); + + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + std::string process_type = + command_line->GetSwitchValueASCII(::switches::kProcessType); + + // Measure time only for browser process. This method gets called by the + // browser process on startup, as well as on renderer and extension + // processes throughout the execution of the browser. We are more + // interested in how long this takes as a startup cost, so we are + // just measuring the time in the browser process. + if (process_type == std::string()) { + UMA_HISTOGRAM_TIMES("Extensions.FeatureProviderStaticInitTime", + base::Time::Now() - begin_time); + } } typedef std::map > -- cgit v1.1