function PdfBenchmarkStatusName(Status: TPdfBenchmarkStatus): string;
function RunPdfBenchmarkCorpus(const Cases: array of TPdfBenchmarkCase; const Options: TPdfBenchmarkOptions; const CancellationToken: IPdfCancellationToken = nil): TPdfBenchmarkReport;
function RunPdfBenchmarkFiles(const FileNames: array of string; const Options: TPdfBenchmarkOptions; const CancellationToken: IPdfCancellationToken = nil): TPdfBenchmarkReport;
| Type | Description |
|---|---|
TPdfBenchmarkStatus | 終端狀態:pbsPassed、pbsFailed 或 pbsSkipped |
TPdfBenchmarkCase | 輸入路徑、選用密碼、增強識別碼、顯示名稱,以及選用的預期語意與像素雜湊 |
TPdfBenchmarkCases | TPdfBenchmarkCase 值的動態陣列 |
TPdfBenchmarkOptions | 暖機與量測趟數、頁面與像素額度、算繪選項、雜湊選擇、獨立重新開啟閘門、取樣間隔、取消與失敗政策 |
TPdfBenchmarkCaseResult | 單一案例結果,含位元組大小、頁數、計時、輸送量、工作集取樣、雜湊、穩定性閘門、重新開啟閘門與失敗證據 |
TPdfBenchmarkCaseResults | TPdfBenchmarkCaseResult 值的動態陣列 |
TPdfBenchmarkReport | 排序後的案例結果,含彙總計數器、一致性狀態、JSON 匯出與 CSV 匯出 |
| Member | Description |
|---|---|
PdfBenchmarkStatusName | 傳回 TPdfBenchmarkStatus 值的穩定顯示名稱 |
TPdfBenchmarkCase.FromFile | 從檔案路徑建立案例,可附帶增強識別碼與顯示名稱 |
TPdfBenchmarkOptions.Default | 傳回暖機、量測、算繪、雜湊、重新開啟驗證與記憶體取樣的有界預設值 |
TPdfBenchmarkCaseResult.IsPassed | 當案例狀態為 pbsPassed 時傳回 True |
TPdfBenchmarkReport.PassedCount / FailedCount / SkippedCount | 依終端狀態統計結果數量 |
TPdfBenchmarkReport.IsConformant | 只有在執行未被取消且所有案例都通過時才傳回 True |
TPdfBenchmarkReport.ToJson / ToCsv | 將完整報告序列化為 JSON 或 CSV 文字 |
TPdfBenchmarkReport.SaveJsonToFile / SaveCsvToFile | 將序列化後的報告寫入 UTF-8 檔案 |
RunPdfBenchmarkCorpus | 以指定的選項與取消權杖執行完整描述的評測案例 |
RunPdfBenchmarkFiles | 以預設案例中繼資料與指定選項執行檔案名稱清單 |
| Record | Public fields |
|---|---|
TPdfBenchmarkCase | Name、EnhancementId、FileName、Password、ExpectedSemanticHash 與 ExpectedPixelHash |
TPdfBenchmarkOptions | WarmupRuns、MeasuredRuns、MaxPages、RenderWidth、RenderHeight、MaxPixelsPerPage、RenderOptions、BackgroundColor、IncludeSemanticHash、IncludePixelHash、VerifyIndependentReopen、MemorySampleIntervalMs 與 StopOnFailure |
每趟暖機與量測都會從案例路徑開啟全新的 TPdf 實例,透過一般 PDFium 後端 API 載入,算繪有界的頁面子集,計算所需的雜湊,儲存到記憶體,並釋放所有控制代碼
首頁指標合併文件載入與首次有界限頁算繪,因此代表到第一個可用像素為止的時間,而不只是剖析器建構時間
算繪輸送量使用量測的頁數與算繪時長,而 MaxPages、RenderWidth、RenderHeight 與 MaxPixelsPerPage 會在點陣圖配置之前限制工作量
語意 SHA-256 摘要涵蓋頁面順序、頁面尺寸、旋轉與 UTF-16 文字;像素 SHA-256 摘要則涵蓋確定性的點陣圖尺寸與掃描線位元組
啟用獨立重新開啟驗證時,儲存的位元組會載入第二個 TPdf 實例,且頁數、語意雜湊與像素雜湊必須與量測輸入趟相符
當雜湊在量測趟之間不一致、預期雜湊不符、獨立重新開啟改變語意或像素、載入或儲存失敗,或某個有界操作引發錯誤時,該案例即判定失敗
| Field | Meaning |
|---|---|
InputBytes / SavedBytes | 來源檔案長度與 PDFium 儲存輸出長度 |
LoadMilliseconds | 量測所得的平均文件載入時長 |
FirstPageMilliseconds | 平均載入加上首次有界限頁算繪時長 |
RenderMilliseconds / RenderPagesPerSecond | 平均有界算繪時長與推導的頁面輸送量 |
SaveMilliseconds / ReopenMilliseconds | 平均記憶體內儲存與獨立重新開啟驗證時長 |
BaselineWorkingSetBytes / PeakWorkingSetBytes | 各量測趟中最低的基準與最高的取樣處理序工作集 |
PeakWorkingSetIncreaseBytes | 相對於對應趟基準的最大取樣增量 |
SemanticHash / PixelHash | 小寫 SHA-256 摘要,用於穩定性與語料庫預期閘門 |
ReopenSemanticHash / ReopenPixelHash | 從獨立重新開啟的儲存結果計算出的識別值 |
StableAcrossRuns | 當每趟量測都產生相同語意與像素識別值時為 True |
IndependentReopenChecked / IndependentReopenSucceeded | 回報是否要求重新開啟驗證,以及重新開啟是否成功 |
EquivalentAfterReopen | 當獨立重新開啟的儲存結果保留頁數與選定的識別值時為 True |
ExpectedSemanticHashMatched / ExpectedPixelHashMatched | 分別回報每個已設定的語料庫預期閘門 |
| Record | Public fields |
|---|---|
TPdfBenchmarkCaseResult | Name、EnhancementId、FileName、Status、ErrorText、PageCount、PagesRendered、WarmupRuns 與 MeasuredRuns,以及上文列出的量測與閘門欄位 |
TPdfBenchmarkReport | Results 包含排序後的案例結果,Cancelled 記錄終端取消 |
TPdfBenchmarkOptions.Default 啟用語意與像素雜湊、獨立重新開啟檢查、一趟暖機、三趟量測,以及有界算繪TPdfBenchmarkReport.IsConformant 傳回 False
uses FPdfBenchmark;
var
Cases: TPdfBenchmarkCases;
Options: TPdfBenchmarkOptions;
Report: TPdfBenchmarkReport;
begin
SetLength(Cases, 1);
Cases[0] := TPdfBenchmarkCase.FromFile('C:\Corpus\sample.pdf', 100, 'release-sample');
Options := TPdfBenchmarkOptions.Default;
Options.MaxPages := 8;
Options.RenderWidth := 1024;
Report := RunPdfBenchmarkCorpus(Cases, Options);
Report.SaveJsonToFile('C:\Corpus\benchmark.json');
Report.SaveCsvToFile('C:\Corpus\benchmark.csv');
end;