阅读变数大阵列的Andr​​oid最快的方法 [英] Android fastest way of reading big arrays of variables

查看:123
本文介绍了阅读变数大阵列的Andr​​oid最快的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序需要找到加载整数浮动变量的大阵列的更快的方法。什么AVE

In my application I need to find a faster way of loading big arrays of Integer and Float variables. What ave


  1. 创建直接使用Java code阵列 - 这没有工作,因为我的应用程序使用的阵列是非常大的,200 000多个浮点值,导致的java $ C $ ç过大错误,我找不到这方面的任何解决办法。

  1. Creating arrays directly using Java Code - This didn't work, because arrays used by my application are really big, 200 000+ float values, which cause java code too large error and I couldn't find any workaround for this.

尝试使用项目导入这些阵列 XML 这并没有太多工作,因为文件的大小变得非常大,我甚至无法建立。

Tried importing these arrays in project using xml which didn't work too, because file size is getting really big and I can't even build.

这在资产文件夹中的工作,到目前为止,我已经添加了 TXT 文件的东西,阅读他们使用的InputStream ,解析它们作为花车/整数和动态创建数组,但这是太慢了。

The thing which worked so far, I've added txt files in assets folder, read them using InputStream, parse them as floats / integers and create arrays dynamically, but this is too slow.

,我有这些大阵列的原因是,因为我的项目使用Vuforia用于显示3D模型,这需要重新present他们作为花车/整数数组(顶点,textcoords,法线指数),但装12款车型正在太多的时间。

The reason which I have these big arrays is, because my project uses Vuforia for showing 3D Models, which needs to represent them as arrays of floats / integers (vertices,textcoords,normals,indices), but loading 12 Models is taking too much time.

我很想得到一些意见/建议我怎么能加快加载过程。

I would love to get some advices / suggestions how can I speed up the loading process.

在此先感谢!

推荐答案

我没有基准这一点,但(可能)最快的简单的方式来阅读大量的整数和浮点值会使用 DataInputStream以和它的各种的readXXX()方法。

I have not benchmarked this, but (probably) the fastest simple way to read large numbers of integer and floating point values would be to use a DataInputStream and its various readXxx() methods.

如果该数据是同质的,那么你也许可以使用获得更快的传输 FileChannel 的ByteBuffer 键,(说) DoubleBuffer 。此处描述该方法:<一href=\"http://stackoverflow.com/questions/22249483/write-read-float-array-in-java-fast-way\">write/read漂浮在java中快速的方式阵。 (荣誉去@greenapps ...)然而,这将是棘手的,要如果数据是异质工作;即不同原始类型的混合。

If the data is homogeneous, then you can probably get faster transfer using FileChannel, ByteBuffer and (say) DoubleBuffer. This method is described here: "write/read float array in java fast way". (Kudos goes to @greenapps ...) However, it would be tricky to get that to work if the data is heterogeneous; i.e. a mixture of different primitive types.

这篇关于阅读变数大阵列的Andr​​oid最快的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆