Android の SD カードに保存されている大きなファイル (50MB から 100MB) を読み取るのにかかる時間 (概算) を知りたいです。Google Nexus One の Android 2.3.3 で次のコードを使用しています。これで妥当な見積もりが得られますか? 使用すべき標準的な方法はありますか? また、ネイティブ コードを使用するとファイル I/O パフォーマンスが向上しますか?
ありがとう。
public void readFileFromSDCard() throws IOException
{
long start = System.currentTimeMillis();
long size = 0;
File file = new File(OVERLAY_PATH_BASE + "base-ubuntu.vdi");
try {
InputStream in = new FileInputStream(file);
try {
byte[] tmp = new byte[4096];
int l;
while ((l = in.read(tmp)) != -1) {
size = size + 4096;
}
} finally {
in.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
long end = System.currentTimeMillis();
Log.e(LOG_TAG,
"Reading file " + file.getAbsolutePath() + " with " + size + "bytes took " + (end-start) + " ms.");
}