Commit 70895713 authored by Mei Liang's avatar Mei Liang Committed by Commit Bot

Fix the casting error when recording tasks UMA

In TasksUma.java, the histogram Tabs.Tasks.TabsInGroupRatio and
Tabs.Tasks.TabGroupDensity requires to record sample in integer format
and have unit in percent. The code had a casting error when we
cast the ratio (in double) to integer first then multiply by 100 to
convert the unit to percent.

This CL fixes the casting error by multiplying the ratio by 100 first
to get the correct unit then cast that result to an integer.

Bug: 856275
Change-Id: Id5d1d6a3450e3d733b27ee437f1e0c3f1fb94d0d
Reviewed-on: https://chromium-review.googlesource.com/1115800Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Mei Liang <meiliang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571938}
parent b0a64211
...@@ -80,9 +80,9 @@ public class TasksUma { ...@@ -80,9 +80,9 @@ public class TasksUma {
RecordHistogram.recordCountHistogram("Tabs.Tasks.TabsInGroupCount", tabsInGroupCount); RecordHistogram.recordCountHistogram("Tabs.Tasks.TabsInGroupCount", tabsInGroupCount);
double tabsInGroupRatio = tabsInGroupCount * 1.0 / totalTabCount; double tabsInGroupRatioPercent = tabsInGroupCount * 1.0 / totalTabCount * 100.0;
RecordHistogram.recordPercentageHistogram( RecordHistogram.recordPercentageHistogram(
"Tabs.Tasks.TabsInGroupRatio", (int) tabsInGroupRatio * 100); "Tabs.Tasks.TabsInGroupRatio", (int) tabsInGroupRatioPercent);
if (tabGroupCount != 0) { if (tabGroupCount != 0) {
int averageGroupSize = tabsInGroupCount / tabGroupCount; int averageGroupSize = tabsInGroupCount / tabGroupCount;
...@@ -91,14 +91,14 @@ public class TasksUma { ...@@ -91,14 +91,14 @@ public class TasksUma {
Log.d(TAG, "AverageGroupSize: %d", averageGroupSize); Log.d(TAG, "AverageGroupSize: %d", averageGroupSize);
} }
double tabGroupDensity = tabGroupCount * 1.0 / totalTabCount; double tabGroupDensityPercent = tabGroupCount * 1.0 / totalTabCount * 100.0;
RecordHistogram.recordPercentageHistogram( RecordHistogram.recordPercentageHistogram(
"Tabs.Tasks.TabGroupDensity", (int) tabGroupDensity * 100); "Tabs.Tasks.TabGroupDensity", (int) tabGroupDensityPercent);
Log.d(TAG, "TotalTabCount: %d", totalTabCount); Log.d(TAG, "TotalTabCount: %d", totalTabCount);
Log.d(TAG, "TabGroupCount: %d", tabGroupCount); Log.d(TAG, "TabGroupCount: %d", tabGroupCount);
Log.d(TAG, "TabsInGroupCount: %d", tabsInGroupCount); Log.d(TAG, "TabsInGroupCount: %d", tabsInGroupCount);
Log.d(TAG, "TabsInGroupRatio: %f", tabsInGroupRatio); Log.d(TAG, "TabsInGroupRatioPercent: %d", (int) tabsInGroupRatioPercent);
Log.d(TAG, "TabGroupDensity: %f", tabGroupDensity); Log.d(TAG, "TabGroupDensityPercent: %d", (int) tabGroupDensityPercent);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment