The existing algorithm to compute the min and max of the set of samples in chart_base_2d is O(N^2) in the case of power samples, since it loops through all the power samples and all the chart series (and the number of chart series is proportional to the number of power samples, since there's a separate chart series per frame).
The existing algorithm to compute the min and max of the set of samples in chart_base_2d is O(N^2) in the case of power samples, since it loops through all the power samples and all the chart series (and the number of chart series is proportional to the number of power samples, since there's a separate chart series per frame).

Here we fix this algorithm to only be O(N).

frame_power_usage_chart_perf_test [without change]: ~1700 ms
frame_power_usage_chart_perf_test [with change]: ~350 ms

BUG=catapult:#2300

Review-Url: https://codereview.chromium.org/1938093002

benschmaus/catapult,catapult-project/catapult,catapult-project/catapult,catapult-project/catapult-csm,sahiljain/catapult,catapult-project/catapult-csm,benschmaus/catapult,catapult-project/catapult-csm,catapult-project/catapult,sahiljain/catapult,benschmaus/catapult,sahiljain/catapult,catapult-project/catapult,catapult-project/catapult-csm,sahiljain/catapult,benschmaus/catapult,catapult-project/catapult-csm,benschmaus/catapult,sahiljain/catapult,benschmaus/catapult,sahiljain/catapult,catapult-project/catapult,catapult-project/catapult,catapult-project/catapult,catapult-project/catapult-csm,benschmaus/catapult,catapult-project/catapult-csm