求助: Appium+python 採集 iOS 客戶端效能資料, 無法用 instruments 開啟

huhu發表於2020-07-14

最近嘗試做最基礎的客戶端效能測試,
我司是使用appium + python 做的UI自動化測試,
看了這個文章 ,appium 可以採集iOS / Android 的效能資料 (此文為iOS)

https://appiumpro.com/editions/12-capturing-performance-data-for-native-ios-apps

因此我想使用appium將performance資料採集直接寫在UI自動化框架裡。

這篇文章是使用 java存成zip檔案, 解壓就能用instruments開啟,如下:

File traceZip = new File("/path/to/trace.zip");
String b64Zip = (String)driver.executeScript("mobile: stopPerfRecord", args);
byte[] bytesZip = Base64.getMimeDecoder().decode(b64Zip);
FileOutputStream stream = new FileOutputStream(traceZip);
stream.write(bytesZip);

At this point, we'll have a nice little trace.zip sitting at the specified location on disk. We can now simply unzip it and double-click it to open the trace file up in the Instruments viewer:

我對照著寫成了python, 也可以生成.zip檔案,但是解壓縮後的檔案不是xxx.trace, 而是一個資料夾,無法用instruments開啟

b64Zip = str(driver.execute_script('mobile: stopPerfRecord', {'profileName': 'Time Profiler'}))
bytesZip = base64.b64decode(b64Zip)

with open('trace.zip', 'wb') as fz:
fz.write(bytesZip)

我解壓後是這樣的目錄結構:

在網上找了很久,都沒有找到相關的內容,感覺appium採集performance資料好像使用的很少
所以想問下有沒有大佬遇到過這種問題,是怎麼解決的呢?

相關文章