0

We are trying to encode GIF using Animated-gif-Encoder-For-Android. We found that the time taken to encode for same GIF on Lollipop devices is much less than time taken on Marshmallow devices. Major part of encoding GIF is pure arithmetic to quantise colours.

To investigate further we tested with a sample loop of int arithmetic functions.

We found that on

Moto G4 Plus(Android 6.0.1) - it took : 70 ms

Moto E2(Android 5.1) - it took : 25 ms

Can anyone explain this behaviour ? Moto G4 is definitely a more powerful processor than Moto E2. Is it something to do with the Android compiler that changed between Android 5.1 & Android 6.0.1 ???

Specs: http://www.gsmarena.com/motorola_moto_g4_plus-8050.php
http://www.gsmarena.com/motorola_moto_e_(2nd_gen)-6986.php

Sample Code that was profiled:

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));
}
surya
  • 607
  • 5
  • 18
  • There is way too much confounding for this to be possibly endemic of anything. This is just an anecdotal experiment. – Eli Sadoff Nov 03 '16 at 16:31
  • I have tested the same on 4 devices which have version of android > Marshmallow. – surya Nov 03 '16 at 16:52
  • The only way you'll be able to start possibly drawing conclussions is running on the same device with different versions of android and running those programs many times to get averages so outliers don't affect your result. [This](https://cirt.gcu.edu/research/developmentresources/research_ready/experimental/steps_exp_res) might be useful. – Eli Sadoff Nov 03 '16 at 16:54
  • This is a real case . We are actually trying to encode GIF using Animated-gif-Encoder-For-Android. We found that the time taken to encode for same GIF on devices < 6.0 is much less than time taken on devices > 6.0. To simplify the problem we tested with the above profiling function. – surya Nov 04 '16 at 01:56

0 Answers0