Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Optimal Buffer Size

Tags:

android

buffer

In java there is an optimal buffer size of 32 Kb which is based solely on the cpu architecture being used. On Android phones does the Dalvik VM dynamically know the proper cache of the cpu to get the largest buffer size independent of the many different phones out there? If so how would I figure that out at runtime?

Say I want to optimize a audio recording activity by making the buffer the largest it can be and also the fastest. I know you can get the minimal size for it but what about the optimal size?

like image 271
L7ColWinters Avatar asked Apr 13 '12 15:04

L7ColWinters


People also ask

What is the optimal buffer size?

A good buffer size for recording is 128 samples, but you can also get away with raising the buffer size up to 256 samples without being able to detect much latency in the signal. You can also decrease the buffer size below 128, but then some plugins and effects may not run in real time.

Is higher buffer size better?

Increasing the buffer size will allow more time for the audio to be captured without distortion. It is important to find the right buffer size for your session as this can vary depending on the number of tracks, plug-ins, audio files etc.

What is logger buffer size in Android phone?

Logger Buffer Sizes option allows you to change the buffer size of these mentioned buffers. Increasing the buffer size would allow you to capture more logs in the buffer, and reducing the probability of an overwrite in case of high-frequency logs. Setting the option to "OFF" would disable logging.

What is the best buffer size for streaming?

A buffer size less than 0.5 s results in a severe loss of QoE for all users. A buffer size of 2-4 s offers a good QoE for the average user and any sensitive user. Increasing the buffer size further decreases the QoE.


1 Answers

Maybe it depends on what device you have or mind.

However, experimentally, 8K < buffer size < 32K does work well and there are significant performance improvements under 8K. Somewhat interesting is that some data with buffer > 64K showed poorer performance than data with under 64K buffer

(I've tested on several android devices and tried to read 20MB binary file with various buffer size.)

Here's exp result and you'd better to paste them to spreadsheet if you wanna convert data in pretty form. header means buffer size and units are millisecond

graph: http://fb.com/photo.php?fbid=468345876512381

                   128     256     512     1K      2K      4K      8K      16K     32K     64K     128K    256K    512K    1M      2M      4M      8M      16M
    Galaxy S       4047    3060    269     155     100     65      64      52      51      45      47      50      49      43      44      46      45      58
    Optimus LTE    1178    617     322     172     101     65      47      42      41      35      36      39      44      61      56      51      72      60
    HTC EVO        3971    1884    941     480     251     141     95      69      56      50      48      55      50      49      48      48      48      47         
    Galaxy S2      750     383     210     123     74      50      41      37      35      34      34      37      39      44      46      44      45      44
    Galaxy Nexus   2272    1216    659     341     187     108     70      52      41      38      38      45      44      54      56      66      68      58
    Galaxy Note    1549    799     404     220     127     75      58      54      52      56      52      45      44      62      43      39      44      46

InputStream in = openFileInput(FILE_NAME);
startTime = System.currentTimeMillis();

while (in.read(buffer) > 0) {
    readCount++;
}

elapsedTime = System.currentTimeMillis() - startTime;

enter image description here

like image 120
Joon Hong Avatar answered Oct 04 '22 03:10

Joon Hong