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

Unified Diff: chrome/browser/chromeos/input_method/input_method_manager_impl.cc

Issue 1237493003: Uses Hash values for sparse histograms for InputMethod.ID statistics. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/input_method/input_method_manager_impl.cc
diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
index bff428cf90affa2c97936a29952c3c3809a76663..2bc7a784cb87168f6cbc60a0b308b3253f623e76 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/bind.h"
+#include "base/hash.h"
#include "base/location.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/histogram.h"
@@ -863,22 +864,10 @@ InputMethodManagerImpl::InputMethodManagerImpl(
util_.ResetInputMethods(descriptors);
// Initializes the stat id map.
- std::map<int, std::vector<std::string> > buckets;
for (InputMethodDescriptors::const_iterator it = descriptors.begin();
it != descriptors.end(); ++it) {
- char first_char;
- int cat_id = static_cast<int>(
- GetInputMethodCategory(it->id(), &first_char));
- int key = cat_id * 1000 + first_char;
- buckets[key].push_back(it->id());
- }
- for (std::map<int, std::vector<std::string>>::iterator i =
- buckets.begin(); i != buckets.end(); ++i) {
- std::sort(i->second.begin(), i->second.end());
- for (size_t j = 0; j < i->second.size() && j < 100; ++j) {
- int key = i->first * 100 + j;
- stat_id_map_[i->second[j]] = key;
- }
+ std::string id = it->id();
+ stat_id_map_[id] = (int)base::SuperFastHash(id.c_str(), id.length());
Seigo Nonaka 2015/07/16 08:24:47 nit: please use static_cast<int>
Shu Chen 2015/07/16 08:57:27 Done.
}
}
@@ -892,8 +881,7 @@ void InputMethodManagerImpl::RecordInputMethodUsage(
UMA_HISTOGRAM_ENUMERATION("InputMethod.Category",
GetInputMethodCategory(input_method_id),
INPUT_METHOD_CATEGORY_MAX);
- UMA_HISTOGRAM_SPARSE_SLOWLY("InputMethod.ID",
- stat_id_map_[input_method_id]);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("InputMethod.ID2", stat_id_map_[input_method_id]);
}
void InputMethodManagerImpl::AddObserver(
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698