使用LogCat记录器来捕获日志并在控制台中查看运行结果。以下是一个示例:
import android.os.Debug;
public class MyBenchmark { public static void main(String[] args) { Debug.startMethodTracing("myBenchmark");
// run benchmark code here
Debug.stopMethodTracing();
// print logs to console
String log = "";
for (String s : Debug.getSupportedGpuDebugLayers()) {
log += s + "\n";
}
System.out.println(log);
} }
在上面的代码中,我们使用Debug.startMethodTracing和Debug.stopMethodTracing来记录基准测试运行,并使用Debug.getSupportedGpuDebugLayers获取支持的GPU调试层。我们然后将日志打印到控制台上,以便查看运行结果。