AtraceLogger

public class AtraceLogger
extends Object

java.lang.Object
   ↳ android.support.test.rule.logging.AtraceLogger


Class包含助手方法,在运行测试用例的同时异步地转储atrace信息

Summary

Public methods

void atraceStart(Set<String> traceCategoriesSet, int atraceBufferSize, int dumpIntervalSecs, File destDirectory, String traceFileName)

以定期间隔启动atrace并转储数据的方法。

void atraceStop()

停止atrace并将字节数组列表中缓存的atrace数据写入文件的方法。

static AtraceLogger getAtraceLoggerInstance(Instrumentation instrumentation)

确保只创建一个atrace记录器的一个实例。

Inherited methods

From class java.lang.Object

Public methods

atraceStart

void atraceStart (Set<String> traceCategoriesSet, 
                int atraceBufferSize, 
                int dumpIntervalSecs, 
                File destDirectory, 
                String traceFileName)

以定期间隔启动atrace并转储数据的方法。 注意:如果atraceStart和atraceStop之间存在多个转储,则在转储期间不会捕获跟踪信息

Parameters
traceCategoriesSet Set: Set of atrace categories (i.e atrace --list_categories)
atraceBufferSize int: Size of the circular buffer in kb
dumpIntervalSecs int: Periodic interval to dump data from circular buffer
destDirectory File: Directory under which atrace logs are stored
traceFileName String: is optional parameter.Atrace files are dumped under destDirectory. traceFileName will be indexed based on number of dumps between atraceStart and atraceStop under destDirectory. If traceFileName is null or empty "atrace" name will be used for indexing the files and stored under destDirectory
Throws
IOException

atraceStop

void atraceStop ()

停止atrace并将字节数组列表中缓存的atrace数据写入文件的方法。

Throws
IOException
InterruptedException
IOException

getAtraceLoggerInstance

AtraceLogger getAtraceLoggerInstance (Instrumentation instrumentation)

确保只创建一个atrace记录器的一个实例。 注意:由于UiAutomation executeShellCommand限制,仅支持minsdk版本23及更高版本。

Parameters
instrumentation Instrumentation: Used to execute atrace shell commands
Returns
AtraceLogger instance of the AtraceLogger