OLD | NEW |
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 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 type(basename + same_version_startup_count_suffix, \ | 251 type(basename + same_version_startup_count_suffix, \ |
252 value_same_version_count); \ | 252 value_same_version_count); \ |
253 } \ | 253 } \ |
254 } while (0) | 254 } while (0) |
255 | 255 |
256 #define UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE(type, basename, begin_ticks, \ | 256 #define UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE(type, basename, begin_ticks, \ |
257 end_ticks) \ | 257 end_ticks) \ |
258 do { \ | 258 do { \ |
259 UMA_HISTOGRAM_WITH_TEMPERATURE(type, basename, end_ticks - begin_ticks); \ | 259 UMA_HISTOGRAM_WITH_TEMPERATURE(type, basename, end_ticks - begin_ticks); \ |
260 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( \ | 260 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( \ |
261 "startup", basename, 0, begin_ticks.ToInternalValue(), "Temperature", \ | 261 "startup", basename, 0, begin_ticks, "Temperature", \ |
262 g_startup_temperature); \ | 262 g_startup_temperature); \ |
263 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP1( \ | 263 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP1( \ |
264 "startup", basename, 0, end_ticks.ToInternalValue(), "Temperature", \ | 264 "startup", basename, 0, end_ticks, "Temperature", \ |
265 g_startup_temperature); \ | 265 g_startup_temperature); \ |
266 } while (0) | 266 } while (0) |
267 | 267 |
268 #define UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( \ | 268 #define UMA_HISTOGRAM_AND_TRACE_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( \ |
269 type, basename, begin_ticks, end_ticks) \ | 269 type, basename, begin_ticks, end_ticks) \ |
270 do { \ | 270 do { \ |
271 UMA_HISTOGRAM_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( \ | 271 UMA_HISTOGRAM_WITH_TEMPERATURE_AND_SAME_VERSION_COUNT( \ |
272 type, basename, end_ticks - begin_ticks); \ | 272 type, basename, end_ticks - begin_ticks); \ |
273 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP2( \ | 273 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP2( \ |
274 "startup", basename, 0, begin_ticks.ToInternalValue(), "Temperature", \ | 274 "startup", basename, 0, begin_ticks, "Temperature", \ |
275 g_startup_temperature, "Startups with current version", \ | 275 g_startup_temperature, "Startups with current version", \ |
276 g_startups_with_current_version); \ | 276 g_startups_with_current_version); \ |
277 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP2( \ | 277 TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP2( \ |
278 "startup", basename, 0, end_ticks.ToInternalValue(), "Temperature", \ | 278 "startup", basename, 0, end_ticks, "Temperature", \ |
279 g_startup_temperature, "Startups with current version", \ | 279 g_startup_temperature, "Startups with current version", \ |
280 g_startups_with_current_version); \ | 280 g_startups_with_current_version); \ |
281 } while (0) | 281 } while (0) |
282 | 282 |
283 std::string GetSameVersionStartupCountSuffix() { | 283 std::string GetSameVersionStartupCountSuffix() { |
284 // TODO(fdoray): Remove this once crbug.com/580207 is fixed. | 284 // TODO(fdoray): Remove this once crbug.com/580207 is fixed. |
285 if (g_startups_with_current_version == | 285 if (g_startups_with_current_version == |
286 kUndeterminedStartupsWithCurrentVersion) { | 286 kUndeterminedStartupsWithCurrentVersion) { |
287 return std::string(); | 287 return std::string(); |
288 } | 288 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 browser_main_entry_point_ticks, renderer_main_entry_point_ticks); | 465 browser_main_entry_point_ticks, renderer_main_entry_point_ticks); |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 void AddStartupEventsForTelemetry() | 469 void AddStartupEventsForTelemetry() |
470 { | 470 { |
471 DCHECK(!g_browser_main_entry_point_ticks.Get().is_null()); | 471 DCHECK(!g_browser_main_entry_point_ticks.Get().is_null()); |
472 | 472 |
473 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( | 473 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( |
474 "startup", "Startup.BrowserMainEntryPoint", 0, | 474 "startup", "Startup.BrowserMainEntryPoint", 0, |
475 g_browser_main_entry_point_ticks.Get().ToInternalValue()); | 475 g_browser_main_entry_point_ticks.Get()); |
476 | 476 |
477 if (!g_process_creation_ticks.Get().is_null()) | 477 if (!g_process_creation_ticks.Get().is_null()) |
478 { | 478 { |
479 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( | 479 TRACE_EVENT_INSTANT_WITH_TIMESTAMP0( |
480 "startup", "Startup.BrowserProcessCreation", 0, | 480 "startup", "Startup.BrowserProcessCreation", 0, |
481 g_process_creation_ticks.Get().ToInternalValue()); | 481 g_process_creation_ticks.Get()); |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 // Logs the Startup.TimeSinceLastStartup histogram. Obtains the timestamp of the | 485 // Logs the Startup.TimeSinceLastStartup histogram. Obtains the timestamp of the |
486 // last startup from |pref_service| and overwrites it with the timestamp of the | 486 // last startup from |pref_service| and overwrites it with the timestamp of the |
487 // current startup. If the startup temperature has been set by | 487 // current startup. If the startup temperature has been set by |
488 // RecordBrowserMainMessageLoopStart, the time since last startup is also logged | 488 // RecordBrowserMainMessageLoopStart, the time since last startup is also logged |
489 // to a histogram suffixed with the startup temperature. | 489 // to a histogram suffixed with the startup temperature. |
490 void RecordTimeSinceLastStartup(PrefService* pref_service) { | 490 void RecordTimeSinceLastStartup(PrefService* pref_service) { |
491 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) | 491 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(OS_LINUX) |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 UMA_HISTOGRAM_LONG_TIMES_100, | 768 UMA_HISTOGRAM_LONG_TIMES_100, |
769 "Startup.FirstWebContents.MainNavigationFinished", | 769 "Startup.FirstWebContents.MainNavigationFinished", |
770 g_process_creation_ticks.Get(), ticks); | 770 g_process_creation_ticks.Get(), ticks); |
771 } | 771 } |
772 | 772 |
773 base::TimeTicks MainEntryPointTicks() { | 773 base::TimeTicks MainEntryPointTicks() { |
774 return g_browser_main_entry_point_ticks.Get(); | 774 return g_browser_main_entry_point_ticks.Get(); |
775 } | 775 } |
776 | 776 |
777 } // namespace startup_metric_utils | 777 } // namespace startup_metric_utils |
OLD | NEW |