匯入資料¶
在文字檔中匯入資料¶
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 知道如何對執行進行排序。請注意,執行不限於結構描述中針對執行和機器資訊定義的欄位。結構描述中的欄位僅宣告哪些金鑰在資料庫中擁有自己的欄位,以及在使用者介面中的偏好處理方式。