Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android/Linux上的进程监控_Java_Android_Linux_Performance - Fatal编程技术网

Java Android/Linux上的进程监控

Java Android/Linux上的进程监控,java,android,linux,performance,Java,Android,Linux,Performance,我想监控我的Android手机的进程。到目前为止,我的方法是在运行时执行命令。然后解析输出。我所面临的问题是,读取这些数据并不省时。大约需要900毫秒到1300毫秒 下面是代码示例: String cmd = "cat /proc/[0-9]*/status"; Process process = Runtime.getRuntime().exec(new String[]{"sh", "-c", cmd}); BufferedReader reader = new BufferedReader

我想监控我的Android手机的进程。到目前为止,我的方法是在运行时执行命令。然后解析输出。我所面临的问题是,读取这些数据并不省时。大约需要900毫秒到1300毫秒

下面是代码示例:

String cmd = "cat /proc/[0-9]*/status";
Process process = Runtime.getRuntime().exec(new String[]{"sh", "-c", cmd});
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
在此之后,我使用
.readLine()循环读卡器

我怎样才能优化这个,或者什么不同的方法值得一试

谢谢你的帮助