Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 14bbb8a7 authored by Kweku Adams's avatar Kweku Adams
Browse files

Improve forEach.

The default implementation of Collection.forEach() uses the
iterator(). Switch to straight iterating through the array since the
iterator is an inefficient way to access the array contents.

Benchmark results:

Before:

android.util.ArraySetPerfTest#testForEach_Large:
	forEach_Large_median (ns): 398480
	forEach_Large_min (ns): 395758
	forEach_Large_mean (ns): 400957
	forEach_Large_standardDeviation: 5457
android.util.ArraySetPerfTest#testForEach_Small:
	forEach_Small_min (ns): 82768
	forEach_Small_median (ns): 83884
	forEach_Small_standardDeviation: 896
	forEach_Small_mean (ns): 83724

After:

android.util.ArraySetPerfTest#testForEach_Large:
	forEach_Large_median (ns): 319481
	forEach_Large_min (ns): 316166
	forEach_Large_mean (ns): 339865
	forEach_Large_standardDeviation: 44201
android.util.ArraySetPerfTest#testForEach_Small:
	forEach_Small_min (ns): 58736
	forEach_Small_median (ns): 60648
	forEach_Small_standardDeviation: 1375
	forEach_Small_mean (ns): 60622

Bug: 194098491
Test: atest CorePerfTests:ArraySetPerfTest (see results above)
Test: atest CtsUtilTestCases:ArraySetTest
Test: atest FrameworksCoreTests:ArraySetTest
Change-Id: Ib14b96f095203e1f5811132f2a21be0452645f7e
parent 7efcc4df
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment