Android的最佳缓冲区大小

编程入门 行业动态 更新时间:2024-10-19 03:27:32
本文介绍了Android的最佳缓冲区大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Java中的32 KB的最佳缓冲区大小是所使用的CPU架构完全基于。在Android手机并Dalvik虚拟机动态地了解CPU,以获得最大的缓冲区大小无关的许多不同的手机在那里的正确缓存?如果是的话,我将如何可以认识到这一点在运行时?

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?

推荐答案

也许这取决于你拥有或心灵什么设备。

Maybe it depends on what device you have or mind.

然而,实验, 8K<缓冲区的大小和LT; 32K 确实运作良好,有8K下显著的性能提升。有些有趣的是,与缓存一些数据> 64K显示,在64K缓冲区

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

(我已经在几款Android设备的测试,并试图读取各种缓冲区大小为20MB的二进制文件。)

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

下面是EXP的结果,你会更好,如果你想转换成数据,pretty的形式将它们粘贴至S preadsheet。头装置的的缓冲区大小的和单位的毫秒的

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

图:fb/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;

更多推荐

Android的最佳缓冲区大小

本文发布于:2023-11-08 07:23:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1568719.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓冲区   大小   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!