我们正在尝试使用Animated-gif-Encoder-For-Android对GIF进行编码。我们发现在Lollipop设备上编码相同GIF所花费的时间比在Marshmallow设备上花费的时间少得多。编码GIF的主要部分是用于量化颜色的纯算法。
为了进一步研究,我们使用int算术函数的样本循环进行了测试。
我们在
上找到了Moto G4 Plus(Android 6.0.1) - 耗时:70毫秒
Moto E2(Android 5.1) - 花了25毫秒
任何人都可以解释这种行为吗? Moto G4绝对是比Moto E2更强大的处理器。 是否与在Android 5.1和Android之间发生变化的Android编译器有关。 Android 6.0.1 ???
规格:
http://www.gsmarena.com/motorola_moto_g4_plus-8050.php
http://www.gsmarena.com/motorola_moto_e_(2nd_gen)-6986.php
已分析的示例代码:
private void profilingFuntion(){
int N = 1000; // input array size
int k = 1000; // number of mathematical operations performed on each element
// generate random data
int[] ints = new int[N];
int[] doubles = new int[N];
Random r = new Random(1l);
for (int i = 0; i < N; i++) {
ints[i] = r.nextInt();
doubles[i] = r.nextInt();
}
// measure integer subtractions
long before = System.currentTimeMillis();
for (int i = 1; i < N; i++) {
for (int j = 0; j < k; j++) {
ints[i] -= ints[i-1]; // referring to another element might prevent from optimization also
}
}
if(DEBUG)
Log.d(TAG,"time taken for sub:"+(System.currentTimeMillis()-before));
// measure integer subtractions
before = System.currentTimeMillis();
for (int i = 1; i < N; i++) {
for (int j = 0; j < k; j++) {
doubles[i] += doubles[i-1];
}
}
if(DEBUG)
Log.d(TAG,"time taken for add:"+(System.currentTimeMillis()-before));
}