繁体   English   中英

如何对 android 应用程序进行基准测试?

[英]How to benchmark android application?

在工作中,我使用 Ubuntu,在家使用 windows 7. 我想知道如何在 Ubuntu 和 windows 上对我的 android 应用程序进行基准测试 7.

您可以使用DDMS和Systrace分解您的应用程序在做什么以及持续多长时间。

至于“基准化”,那是什么意思? 您是否想查看在应用程序中执行操作需要多长时间? 通常,确保您以最快的方式(而不是在特定的时间范围内)执行操作通常会更有用。

我写了一个代码,专门对我想要的代码的特定部分进行基准测试。 您可以在这里找到它: http : //farzad.devbro.com/android_benchmark/Devbro_Benchmark.java

这是要使用的代码示例:

Devbro_Benchmark.markStart("Label2"); //mark a begining
for(int i=0;i<1000;i++)
{
    //you can create multiple markers at once. If you use the same marker name
    //it will simply add up the times for you
    Devbro_Benchmark.markStart("Label1");
    //some random code
    Devbro_Benchmark.markEnd("Label");
}
Devbro_Benchmark.markEnd("Label2"); // mark an ending

//once you are done with your markers you can display an extensive report which will be
//shown using the Log.d
Devbro_Benchmark.print_report();

//once you are done you can reset before redoing it.
Devbro_Benchmark.reset();

现在有两个 Jetpack 基准测试库 来自 Android 团队。

基准测试:允许您对整个工作流程进行基准测试

Microbenchmarking :启用单独的基准测试特定代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM