本文内容主要來自于:https://chromium.googlesource.com/catapult/+/HEAD/README.md
文章目錄
- Catapult 性能看闆 = Telemetry + Performance Dashboard
- Telemetry:自動化測試架構
-
- 設計原則
- 代碼概念
-
- 測試自動化
- 資料收集
- Performance Dashboard:圖形化性能看闆
-
- 資料協定
- 前端展示政策
- Catapult 性能看闆的優缺點分析
-
- 優點
- 缺點
Catapult 性能看闆 = Telemetry + Performance Dashboard
Catapult 是Chrome/Chromium/Chromium OS所使用的一系列性能工具的組合,包含:Trace-viewer、Telemetry、Performance Dashboard、Systrace、Web Page Replay 等各種工具。
但是在性能看闆的解決方案上,Catapult 提供的如下的解決方案:
- Telemetry:自動化測試架構
- Performance Dashboard:圖形化性能看闆
Chromium 項目公開性能看闆:https://chromeperf.appspot.com/
Telemetry:自動化測試架構
設計原則
Telemetry 主要目的适用于衡量性能資料而非測試正确性。它應該具備以下特點:
- 隻用編寫一次測試用例就可以在主要平台中都運作起來
- 僅有浏覽器應用也可執行測試用例,無需源碼配合
- 能夠使使用者故事與測試名額解耦,友善擴充
代碼概念
Telemetry 提供兩個核心功能:測試自動化方案以及收集資料的能力
測試自動化
Telemetry 基于 Python實作,并且針對不同的平台采用不同的方式進行底層控制封裝。
資料收集
Telemetry 的核心功能是收集性能資料,這些資料用于衡量自動化操作過程性能。
- Telemetry 中最小的可測試對象稱為基準(Benchmark),它由故事集( Story Set)、度量( Measurement)以及浏覽器參數(Browser Options)組成。
- 基準(Benchmark)是跨平台的
- 基準(Benchmark)可以被 Telemetry 中的執行器自動發現并運作
- 度量(Measurement)負責自動化測試的 set up 和 tear down,并收集應用程式在測試場景中的名額(Metrics)
- 度量(Measurement)應與任意故事集( Story Set)都能夠協同工作
- 名額(Metrics)描述如何收集并計算資料
- 名額(Metrics)應該盡量基于時間軸
- 名額(Metrics)可以支援以多種形式展現,如數值、直方圖等
- 故事集( Story Set)包含多個故事(Story)以及通用的配置資訊
- 故事(Story)包含場景及其操作指令。例如,一個典型的 Chromium 故事就是:在 http://www.sina.com 頁面(場景)中上下滑動(操作指令)
另外 Timeline Based Measurement 是 Telemetry 中内置的 StoryTest,由官方統一維護
Performance Dashboard:圖形化性能看闆
資料協定
Chrome Performance Dashboard Data Format:
{
"master": "master.chromium.perf",
"bot": "linux-release",
"versions": {
"version type": "version string"
},
"supplemental": {
"field name": "supplemental data string",
"default_rev": "r_chrome_version"
},
"chart_data": {
/*... as output by Telemetry; see below ...*/
}
}
字段名 | 字段類型 | 字段含義 |
---|---|---|
master | string | Buildbot master name or top-level category for data |
bot | string | Buildbot builder name, or platform type for data |
versions | dict | Maps repo name to revision |
supplemental | dict | Key-value pairs which may be displayed on the dashboard |
chart_data | dict | The chart JSON as output by Telemetry |
Chart data:
{
"format_version": "1.0",
"benchmark_name": "page_cycler.typical_25",
"charts": {
"warm_times": {
"http://www.google.com/": {
"type": "list_of_scalar_values",
"values": [9, 9, 8, 9],
},
"http://www.yahoo.com/": {
"type": "list_of_scalar_values",
"values": [4, 5, 4, 4],
"std": 0.5,
},
"summary": {
"type": "list_of_scalar_values",
"values": [13, 14, 12, 13],
"file": "gs://..."
},
},
"html_size": {
"http://www.google.com/": {
"type": "scalar",
"value": 13579,
"units": "bytes"
}
},
"load_times": {
"http://www.google.com/": {
"type": "list_of_scalar_values",
"value": [4.2],
"std": 1.25,
"units": "sec"
}
}
}
}
字段名 | 字段類型 | 字段含義 |
---|---|---|
format_version | string | Allows dashboard to know how to process the structure |
benchmark_name | string | A string to use in the perf dashboard test |
charts | dict of string to dict | Maps a list of chart name strings to their data dicts |
前端展示政策
如下圖所示,幾乎所有資料展示方式基本相同:
Catapult 性能看闆的優缺點分析
優點
概括而言,簡單高效:
- 測試場景非常明确:浏覽器浏覽頁面時的性能資料。這樣的定義使得測試自動化實作非常優雅
- 性能資料類型定義非常明确:可數值化衡量的基準性能資料。這樣的定義使得前端展示方式可以非常簡化
缺點
對于仔細看圖的非基準性能資料,如記憶體穩定性、ROC曲線等缺乏解決方案