mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
// Run a quick-and-dirty performance test: write 512 bytes
byte[] junk = new byte[512];
for (int i = 0; i < junk.length; i++) junk[i] = (byte) i; // Write nonzero bytes
File tmp = new File(Environment.getDataDirectory(), "system/perftest.tmp");
FileOutputStream fos = null;
IOException error = null;
long before = SystemClock.uptimeMillis();
try {
fos = new FileOutputStream(tmp);
fos.write(junk);
} catch (IOException e) {
error = e;
} finally {
try { if (fos != null) fos.close(); } catch (IOException e) {}
}
long after = SystemClock.uptimeMillis();
if (tmp.exists()) tmp.delete();
if (error != null) {
pw.print("Test-Error: ");
pw.println(error.toString());
} else {
pw.print("Latency: ");
pw.print(after - before);
pw.println("ms [512B Data Write]");
}
reportFreeSpace(Environment.getDataDirectory(), "Data", pw);
reportFreeSpace(Environment.getDownloadCacheDirectory(), "Cache", pw);
reportFreeSpace(new File("/system"), "System", pw);
// TODO: Read /proc/yaffs and report interesting values;
// add configurable (through args) performance test parameters.