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

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

Issue 2711623002: Add a TBMv2 webrtc_rendering_metric. (Closed)
Patch Set: Customize summary options. Created 3 years, 9 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: tracing/tracing/base/utils.html
diff --git a/tracing/tracing/base/utils.html b/tracing/tracing/base/utils.html
index a3a6d0c98fb9c4879b2d94c5699682c937048965..106e86f5f5b86cc99c33a242efcd50f0c88385de 100644
--- a/tracing/tracing/base/utils.html
+++ b/tracing/tracing/base/utils.html
@@ -158,6 +158,28 @@ tr.exportTo('tr.b', function() {
return n;
}
+ /**
+ * @param {Array.<T>} ary
+ * @returns {Array.<Object.<T, number>>} The run length encoding of the array
+ * as an array of {value, count} objects.
+ * @template T
+ */
+ function runLengthEncoding(ary) {
+ let encodedArray = [];
+ for (let element of ary) {
+ if (encodedArray.length === 0 ||
+ encodedArray[encodedArray.length - 1].value !== element) {
+ encodedArray.push({
+ value: element,
+ count: 1,
+ });
+ } else {
+ encodedArray[encodedArray.length - 1].count += 1;
+ }
+ }
+ return encodedArray;
+ }
+
return {
addSingletonGetter,
@@ -171,6 +193,8 @@ tr.exportTo('tr.b', function() {
numberFromJson,
getUsingPath,
+
+ runLengthEncoding,
};
});
</script>

Powered by Google App Engine
This is Rietveld 408576698