【问题标题】:Calculate time for TextView rendering performance计算 TextView 渲染性能的时间
【发布时间】:2012-07-20 05:38:04
【问题描述】:

如何计算TextView 渲染一行文本所需的时间?

textView.setText("hello");

【问题讨论】:

  • 记录方法调用前后的时间。但是,它将如何帮助您。

标签: android rendering


【解决方案1】:

您可以扩展 TextView 类并覆盖绘图:

@Override
public void draw(Canvas canvas) {
    //log start time
    super.draw(canvas);
    //log end time
}

【讨论】:

    【解决方案2】:

    在eclipse中使用Android Traceview

    【讨论】:

    【解决方案3】:

    @Maxim 的替代方法是在 setText("hello"); 之前和之后记录

    Log.i(logTag, "start time");
    textView.setText("hello");
    Log.i(logTag, "end time");
    

    如果视图仅在调用setText 之后才呈现,这将不起作用。也许有人可以在评论中确认或否认这一点。

    【讨论】:

      猜你喜欢
      • 2021-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-09
      • 2012-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多