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

Unified Diff: components/ntp_snippets/content_suggestions_metrics.cc

Issue 2619203007: Log suggestion scores in 10 discrete buckets. (Closed)
Patch Set: fixed float literals Created 3 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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/content_suggestions_metrics.cc
diff --git a/components/ntp_snippets/content_suggestions_metrics.cc b/components/ntp_snippets/content_suggestions_metrics.cc
index 4f61eed1fa9af77c9dbb0f6ea8386caaae14bbf1..58b1dff08b329ef8e5a6a95cb479a64cce7e7f7f 100644
--- a/components/ntp_snippets/content_suggestions_metrics.cc
+++ b/components/ntp_snippets/content_suggestions_metrics.cc
@@ -4,6 +4,7 @@
#include "components/ntp_snippets/content_suggestions_metrics.h"
+#include <cmath>
#include <string>
#include <type_traits>
@@ -25,18 +26,19 @@ const char kHistogramCountOnNtpOpened[] =
"NewTabPage.ContentSuggestions.CountOnNtpOpened";
const char kHistogramShown[] = "NewTabPage.ContentSuggestions.Shown";
const char kHistogramShownAge[] = "NewTabPage.ContentSuggestions.ShownAge";
-const char kHistogramShownScore[] = "NewTabPage.ContentSuggestions.ShownScore";
+const char kHistogramShownScore[] =
+ "NewTabPage.ContentSuggestions.ShownScoreNormalized";
const char kHistogramOpened[] = "NewTabPage.ContentSuggestions.Opened";
const char kHistogramOpenedAge[] = "NewTabPage.ContentSuggestions.OpenedAge";
const char kHistogramOpenedScore[] =
- "NewTabPage.ContentSuggestions.OpenedScore";
+ "NewTabPage.ContentSuggestions.OpenedScoreNormalized";
const char kHistogramOpenDisposition[] =
"NewTabPage.ContentSuggestions.OpenDisposition";
const char kHistogramMenuOpened[] = "NewTabPage.ContentSuggestions.MenuOpened";
const char kHistogramMenuOpenedAge[] =
"NewTabPage.ContentSuggestions.MenuOpenedAge";
const char kHistogramMenuOpenedScore[] =
- "NewTabPage.ContentSuggestions.MenuOpenedScore";
+ "NewTabPage.ContentSuggestions.MenuOpenedScoreNormalized";
const char kHistogramDismissedUnvisited[] =
"NewTabPage.ContentSuggestions.DismissedUnvisited";
const char kHistogramDismissedVisited[] =
@@ -168,9 +170,14 @@ void UmaHistogramAge(const std::string& name, const base::TimeDelta& value) {
// This corresponds to UMA_HISTOGRAM_CUSTOM_COUNTS (with min/max appropriate
// for the score of suggestions) for use with dynamic histogram names.
void UmaHistogramScore(const std::string& name, float value) {
- base::Histogram::FactoryGet(name, 1, 100000, 50,
- base::HistogramBase::kUmaTargetedHistogramFlag)
- ->Add(value);
+ // Scores are typically reported in a range of (0,1]. As UMA does not support
+ // floats, we put them on a discrete scale of [1,10]. We keep the extra bucket
+ // 11 for unexpected over-flows as we want to distinguish them from scores
+ // close to 1. For instance, the discrete value 1 represents score values
+ // within (0.0, 0.1].
+ base::LinearHistogram::FactoryGet(
+ name, 1, 11, 12, base::HistogramBase::kUmaTargetedHistogramFlag)
+ ->Add(ceil(value * 10));
Alexei Svitkine (slow) 2017/01/12 18:42:04 Can you use UmaHistogramExactLinear() here?
tschumann 2017/01/13 17:57:23 Yes. That's actually nice! Turns out UmaHistogramL
}
void LogCategoryHistogramEnumeration(const char* base_name,

Powered by Google App Engine
This is Rietveld 408576698