Skip to content

Commit

Permalink
[ash-md] Added Ash.Wallpaper.TimeSpentResizing histogram.
Browse files Browse the repository at this point in the history
This will track the amount of time spent resizing wallpapers.

BUG=710493

Review-Url: https://codereview.chromium.org/2808353003
Cr-Commit-Position: refs/heads/master@{#464521}
  • Loading branch information
bruthig-chromium authored and Commit bot committed Apr 13, 2017
1 parent 8ee20e2 commit 63957e7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/wallpaper/wallpaper_resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/task_runner.h"
#include "components/wallpaper/wallpaper_resizer_observer.h"
#include "third_party/skia/include/core/SkImage.h"
Expand Down Expand Up @@ -121,6 +122,8 @@ WallpaperResizer::~WallpaperResizer() {
}

void WallpaperResizer::StartResize() {
start_calculation_time_ = base::TimeTicks::Now();

SkBitmap* resized_bitmap = new SkBitmap;
if (!task_runner_->PostTaskAndReply(
FROM_HERE,
Expand All @@ -144,6 +147,9 @@ void WallpaperResizer::RemoveObserver(WallpaperResizerObserver* observer) {

void WallpaperResizer::OnResizeFinished(SkBitmap* resized_bitmap) {
image_ = gfx::ImageSkia::CreateFrom1xBitmap(*resized_bitmap);
UMA_HISTOGRAM_TIMES("Ash.Wallpaper.TimeSpentResizing",
base::TimeTicks::Now() - start_calculation_time_);

for (auto& observer : observers_)
observer.OnWallpaperResized();
}
Expand Down
5 changes: 5 additions & 0 deletions components/wallpaper/wallpaper_resizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/time/time.h"
#include "components/wallpaper/wallpaper_layout.h"
#include "components/wallpaper/wallpaper_resizer_observer.h"
#include "skia/ext/image_operations.h"
Expand Down Expand Up @@ -73,6 +74,10 @@ class WALLPAPER_EXPORT WallpaperResizer {

WallpaperLayout layout_;

// The time that StartResize() was last called. Used for recording timing
// metrics.
base::TimeTicks start_calculation_time_;

scoped_refptr<base::TaskRunner> task_runner_;

base::WeakPtrFactory<WallpaperResizer> weak_ptr_factory_;
Expand Down
11 changes: 11 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,17 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>

<histogram name="Ash.Wallpaper.TimeSpentResizing" units="ms">
<owner>bruthig@chromium.org</owner>
<owner>tbuckley@chromium.org</owner>
<summary>
The time taken to resize wallpapers. Recorded once each time the wallpaper
changes (e.g. initial wallpaper loading at boot, switching user avatar at
login screen, switching between logged in users, user selects new wallpaper,
etc).
</summary>
</histogram>

<histogram name="Ash.Wallpaper.Type" enum="WallpaperType">
<owner>kuscher@google.com</owner>
<summary>The wallpaper type. Recorded at user login.</summary>
Expand Down

0 comments on commit 63957e7

Please sign in to comment.