UNPKG

appium-android-driver

Version:

Android UiAutomator and Chrome support for Appium

125 lines 7.83 kB
import type { AndroidDriver } from '../driver'; import type { PerformanceDataType } from './types'; export declare const NETWORK_KEYS: readonly [readonly ["bucketStart", "activeTime", "rxBytes", "rxPackets", "txBytes", "txPackets", "operations", "bucketDuration"], readonly ["st", "activeTime", "rb", "rp", "tb", "tp", "op", "bucketDuration"]]; export declare const CPU_KEYS: readonly ["user", "kernel"]; export declare const BATTERY_KEYS: readonly ["power"]; export declare const MEMORY_KEYS: readonly ["totalPrivateDirty", "nativePrivateDirty", "dalvikPrivateDirty", "eglPrivateDirty", "glPrivateDirty", "totalPss", "nativePss", "dalvikPss", "eglPss", "glPss", "nativeHeapAllocatedSize", "nativeHeapSize", "nativeRss", "dalvikRss", "totalRss"]; export declare const SUPPORTED_PERFORMANCE_DATA_TYPES: Readonly<{ readonly cpuinfo: "the amount of cpu by user and kernel process - cpu information for applications on real devices and simulators"; readonly memoryinfo: "the amount of memory used by the process - memory information for applications on real devices and simulators"; readonly batteryinfo: "the remaining battery power - battery power information for applications on real devices and simulators"; readonly networkinfo: "the network statistics - network rx/tx information for applications on real devices and simulators"; }>; export declare const MEMINFO_TITLES: Readonly<{ readonly NATIVE: "Native"; readonly DALVIK: "Dalvik"; readonly EGL: "EGL"; readonly GL: "GL"; readonly MTRACK: "mtrack"; readonly TOTAL: "TOTAL"; readonly HEAP: "Heap"; }>; /** * Retrieves the list of available performance data types. * * @returns An array of supported performance data type names. * The possible values are: 'cpuinfo', 'memoryinfo', 'batteryinfo', 'networkinfo'. */ export declare function getPerformanceDataTypes(this: AndroidDriver): Promise<PerformanceDataType[]>; /** * Retrieves performance data for the specified data type. * * @param packageName The package name of the application to get performance data for. * Required for 'cpuinfo' and 'memoryinfo' data types. * @param dataType The type of performance data to retrieve. * Must be one of values returned by {@link getPerformanceDataTypes}. * @param retries The number of retry attempts if data retrieval fails. * @returns A two-dimensional array where the first row contains column names * and subsequent rows contain the sampled data values. * @throws {Error} If the data type is not supported or data retrieval fails. */ export declare function getPerformanceData(this: AndroidDriver, packageName: string, dataType: string, retries?: number): Promise<any[][]>; /** * Retrieves performance data about the given Android subsystem. * The data is parsed from the output of the dumpsys utility. * * The output depends on the selected subsystem. * It is orginized into a table, where the first row represent column names * and the following rows represent the sampled data for each column. * Example output for different data types: * - batteryinfo: [[power], [23]] * - memory info: [[totalPrivateDirty, nativePrivateDirty, dalvikPrivateDirty, eglPrivateDirty, glPrivateDirty, totalPss, * nativePss, dalvikPss, eglPss, glPss, nativeHeapAllocatedSize, nativeHeapSize], [18360, 8296, 6132, null, null, 42588, 8406, 7024, null, null, 26519, 10344]] * - networkinfo: [[bucketStart, activeTime, rxBytes, rxPackets, txBytes, txPackets, operations, bucketDuration,], * [1478091600000, null, 1099075, 610947, 928, 114362, 769, 0, 3600000], [1478095200000, null, 1306300, 405997, 509, 46359, 370, 0, 3600000]] * * [[st, activeTime, rb, rp, tb, tp, op, bucketDuration], [1478088000, null, null, 32115296, 34291, 2956805, 25705, 0, 3600], * [1478091600, null, null, 2714683, 11821, 1420564, 12650, 0, 3600], [1478095200, null, null, 10079213, 19962, 2487705, 20015, 0, 3600], * [1478098800, null, null, 4444433, 10227, 1430356, 10493, 0, 3600]] * - cpuinfo: [[user, kernel], [0.9, 1.3]] */ export declare function mobileGetPerformanceData(this: AndroidDriver, packageName: string, dataType: PerformanceDataType): Promise<any[][]>; /** * Retrieves memory information for the specified application package. * * The data is parsed from the output of `dumpsys meminfo` command. * The output format varies depending on the Android API level: * - API 18-29: Contains PSS, private dirty, and heap information * - API 30+: Additionally includes RSS information * * @param packageName The package name of the application to get memory information for. * @param retries The number of retry attempts if data retrieval fails. * @returns A two-dimensional array where the first row contains memory metric names * (totalPrivateDirty, nativePrivateDirty, dalvikPrivateDirty, eglPrivateDirty, * glPrivateDirty, totalPss, nativePss, dalvikPss, eglPss, glPss, * nativeHeapAllocatedSize, nativeHeapSize, nativeRss, dalvikRss, totalRss) * and the second row contains the corresponding values. * @throws {Error} If memory data cannot be retrieved or parsed. */ export declare function getMemoryInfo(this: AndroidDriver, packageName: string, retries?: number): Promise<any[][]>; /** * Retrieves network traffic statistics from the device. * * The data is parsed from the output of `dumpsys netstats` command. * The output format differs between emulators and real devices: * - Emulators: Uses full key names (bucketStart, activeTime, rxBytes, etc.) * - Real devices (Android 7.1+): Uses abbreviated keys (st, rb, rp, tb, tp, op) * * @param retries The number of retry attempts if data retrieval fails. * @returns A two-dimensional array where the first row contains network metric names * (bucketStart/st, activeTime, rxBytes/rb, rxPackets/rp, txBytes/tb, txPackets/tp, * operations/op, bucketDuration) and subsequent rows contain the sampled data * for each time bucket. * @throws {Error} If network traffic data cannot be retrieved or parsed. */ export declare function getNetworkTrafficInfo(this: AndroidDriver, retries?: number): Promise<any[][]>; /** * Return the CPU information related to the given packageName. * It raises an exception if the dumped CPU information did not include the given packageName * or the format was wrong. * The CPU information's sampling interval depends on the device under test. * For example, some devices have 5 minutes interval. When you get the information * from 2023-02-07 11:59:40.468 to 2023-02-07 12:04:40.556, then the next will be * from 2023-02-07 12:04:40.556 to 2023-02-07 12:09:40.668. No process information * exists in the result if the process was not running during the period. * * @param packageName The package name to get the CPU information. * @param retries The number of retry count. * @returns The array of the parsed CPU upsage percentages. * e.g. ['cpuinfo', ['14.3', '28.2']] * '14.3' is usage by the user (%), '28.2' is usage by the kernel (%) * @throws {Error} If it failed to parse the result of dumpsys, or no package name exists. */ export declare function getCPUInfo(this: AndroidDriver, packageName: string, retries?: number): Promise<[typeof CPU_KEYS, [user: string, kernel: string]]>; /** * Retrieves battery level information from the device. * * The data is parsed from the output of `dumpsys battery` command. * * @param retries The number of retry attempts if data retrieval fails. * @returns A two-dimensional array where the first row contains the metric name ['power'] * and the second row contains the battery level as a string (0-100). * @throws {Error} If battery data cannot be retrieved or parsed. */ export declare function getBatteryInfo(this: AndroidDriver, retries?: number): Promise<any[][]>; //# sourceMappingURL=performance.d.ts.map