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

Unified Diff: tracing/tracing/base/statistics.html

Issue 2364243002: Serialize Histograms more efficiently. (Closed)
Patch Set: . Created 4 years, 3 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 | « tracing/tracing/base/running_statistics_test.html ('k') | tracing/tracing/base/statistics_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tracing/tracing/base/statistics.html
diff --git a/tracing/tracing/base/statistics.html b/tracing/tracing/base/statistics.html
index de509f7f646a88e35da5df0af8f23ab40700abd5..785daf9be87597d93fa7e79db75858bf9447a7a6 100644
--- a/tracing/tracing/base/statistics.html
+++ b/tracing/tracing/base/statistics.html
@@ -419,6 +419,23 @@ tr.exportTo('tr.b', function() {
timestamps, opt_absolute, opt_locationCount);
};
+ /**
+ * Modifies |samples| in-place to reduce its length down to |count|.
+ *
+ * @param {!Array} samples
+ * @param {number} count
+ * @return {!Array}
+ */
+ Statistics.uniformlySampleArray = function(samples, count) {
+ if (samples.length <= count) {
+ return samples;
+ }
+ while (samples.length > count) {
+ var i = parseInt(Math.random() * samples.length);
+ samples.splice(i, 1);
+ }
+ return samples;
+ };
/**
* A mechanism to uniformly sample elements from an arbitrary long stream.
« no previous file with comments | « tracing/tracing/base/running_statistics_test.html ('k') | tracing/tracing/base/statistics_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698