匯入資料¶
從文字檔匯入資料¶
LNT 的 importreport 命令會以簡單的文字檔案格式匯入資料。此命令接受以空格分隔的鍵值檔案,並建立可提交至 LNT 伺服器的 LNT 報告檔案。範例輸入檔案
foo.exec 123
bar.size 456
foo/bar/baz.size 789
格式為 “測試名稱.指標”,因此 exec 和 size 是您要提交的測試套件的有效指標。
範例
echo -n "foo.exec 25\nbar.score 24.2\nbar/baz.size 110.0\n" > results.txt
lnt importreport --machine=my-machine-name --order=1234 --testsuite=nts results.txt report.json
lnt submit http://mylnt.com/db_default/submitRun report.json
LNT 報告檔案格式¶
lnt importreport 工具是一種將資料匯入 LNT 測試格式的簡單方法。您也可以直接建立 LNT 報告資料,以獲得更高的彈性。
首先,請確保您已理解 LNT 使用的底層 概念。
{
"format_version": "2",
"machine": {
"name": _String_ // machine name, mandatory
(_String_: _String_)* // optional extra info
},
"run": {
("start_time": "%Y-%m-%dT%H:%M:%S",)? // optional, ISO8061 timestamp
("end_time": "%Y-%m-%dT%H:%M:%S",)? // optional, ISO8061 timestamp, can equal start_time if not known.
(_String_: _String_,)* // optional extra info about the run.
// At least one of the extra fields is used as ordering and is
// mandatory. For the 'nts' and 'Compile' schemas this is the
// 'llvm_project_revision' field.
},
"tests": [
{
"name": _String_, // test name mandatory
(_String_: _Data_)* // List of metrics, _Data_ allows:
// number, string or list of numbers
}+
]
}
一個具體的簡短範例是
{
"format_version": "2",
"machine": {
"name": "LNT-AArch64-A53-O3__clang_DEV__aarch64",
"hardware": "HAL 9000"
},
"run": {
"end_time": "2017-07-18T11:28:23.991076",
"start_time": "2017-07-18T11:28:33.00000",
"llvm_project_revision": "265649",
"compiler_version": "clang 4.0"
},
"tests": [
{
"name": "benchmark1",
"execution_time": [ 0.1056, 0.1055 ],
"hash": "49333a87d501b0aea2191830b66b5eec"
},
{
"name": "benchmark2",
"compile_time": 13.12,
"execution_time": 0.2135,
"hash": "c321727e7e0dfef279548efdb8ab2ea6"
}
]
}
鑑於建立您自己的結果並將其傳送至 LNT 是如此簡單,因此常見的做法是完全不使用 LNT 用戶端應用程式,而僅使用自訂腳本來執行您的測試並將資料提交至 LNT 伺服器。有關如何執行此操作的詳細資訊,請參閱 lnt.testing
預設測試套件 (NTS)¶
預設的測試套件綱要稱為 NTS。它最初是為 llvm 測試套件的夜間測試執行而設計的。但是,它也應適用於許多其他基準測試套件。以下是指標支援的測試
execution_time
: 執行時間(秒);數值越低越好。score
: 基準測試分數;數值越高越好。compile_time
: 編譯時間(秒);數值越低越好。hash
: 具有可執行雜湊值的字串(通常是已剝離二進制檔案的 md5sum)mem_bytes
: 執行期間的記憶體使用量(以位元組為單位);數值越低越好。code_size
: 程式碼大小(通常是文字區段的大小),以位元組為單位;數值越低越好。execution_status
: 非零值表示執行失敗。compile_status
: 非零值表示編譯失敗。hash_status
: 非零值表示計算可執行雜湊值失敗。
預期的 執行 資訊應包含以下內容
llvm_project_revision
: 用於測試的編譯器修訂版本或版本。用於排序執行。
自訂測試套件¶
LNT 測試套件綱要定義了可以追蹤測試的哪些指標,以及關於執行和機器的哪些額外資訊。您可以在 yaml 檔案中定義自己的測試套件綱要。LNT 管理員必須將此 yaml 檔案放置(或符號連結)到伺服器的綱要目錄中。
範例
format_version: '2'
name: my_suite
metrics:
- name: text_size
bigger_is_better: false
type: Real
- name: data_size
bigger_is_better: false
type: Real
- name: score
bigger_is_better: true
type: Real
- name: hash
type: Hash
run_fields:
- name: llvm_project_revision
order: true
machine_fields:
- name: hardware
- name: os
LNT 目前支援以下指標類型
Real
: 8 位元組 IEEE 浮點數值。Hash
: 字串值;限制為 256,sqlite 不會強制執行此限制。Status
: StatusKind 列舉值(目前僅限於 ‘PASS’、‘FAIL’、‘XFAIL’)。
您需要將至少 1 個執行欄位標記為
order: true
,以便 LNT 知道如何排序執行。請注意,執行不限於綱要中為執行和機器資訊定義的欄位。綱要中的欄位僅宣告哪些鍵在資料庫中獲得自己的欄位,以及在 UI 中獲得優先處理。