Sliders have an effect on benchmark execution time

26 Views Asked by At

I wrote an app that measures the execution time of a QR factorization. When the size of the matrix is fixed, hard coded, it behaves admirably and delivers consistent results,

if (ready) {
            initialize();
            rows = 192;
            columns = 120;
            process();
        }

But when I added two sliders to allow the user to easily enter the number of rows and columns, where these two parameters come from the position of the sliders, `columns = (int)slider_1.getValue();

And after the values of the rows and columns have been set from the position of the sliders:

if (rows >= columns) {
            process();
        } else {
            tv_2.setText(String.format(getResources().getString(R.string.err_1), String.valueOf((int)slider_1.getValue())));
        }

the execution time of the algorithm increases markedly, even by a factor of two or greater.

The algorithm itself is buried deep down in the bowels of "process()" and has absolutely no connection to the sliders. The phone is running Android 10, Android Studio version is Giraffe, and the timing is being done by:

    struct timeval  start{}, end{};
    gettimeofday(&start, nullptr);

    long p = complexQR(aPtr, v, qPtr, rows, cols, Q);           // always returns zero

    gettimeofday(&end, nullptr);

    long executionTime = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);

I'm at a loss as to understand why this is happening and whether the ART is getting into the picture. The 192x120 complex matrix normally executes in ~3.5 milliseconds (R only) compared to an AI generated java version at about 100 milliseconds. The method itself is written in arm64-v8a assembly language. Any assistance in helping me understand this phenomena would be greatly appreciated!

0

There are 0 best solutions below