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 | Terminal state with pbsPassed, pbsFailed, or pbsSkipped |
TPdfBenchmarkCase | Input path, optional password, enhancement identifier, display name, and optional expected semantic and pixel hashes |
TPdfBenchmarkCases | Dynamic array of TPdfBenchmarkCase values |
TPdfBenchmarkOptions | Warm-up and measured pass counts, page and pixel budgets, rendering options, hash selection, independent reopen gate, sampling interval, cancellation, and failure policy |
TPdfBenchmarkCaseResult | One case result with byte sizes, page counts, timings, throughput, working-set samples, hashes, stability gates, reopen gates, and failure evidence |
TPdfBenchmarkCaseResults | Dynamic array of TPdfBenchmarkCaseResult values |
TPdfBenchmarkReport | Ordered case results with aggregate counters, conformance status, JSON export, and CSV export |
| Member | Description |
|---|---|
PdfBenchmarkStatusName | Returns the stable display name for a TPdfBenchmarkStatus value |
TPdfBenchmarkCase.FromFile | Creates a case from a file path with optional enhancement identifier and display name |
TPdfBenchmarkOptions.Default | Returns bounded defaults for warm-up, measurement, rendering, hashing, reopen validation, and memory sampling |
TPdfBenchmarkCaseResult.IsPassed | Returns True when the case status is pbsPassed |
TPdfBenchmarkReport.PassedCount / FailedCount / SkippedCount | Count results by terminal status |
TPdfBenchmarkReport.IsConformant | Returns True only when the run was not cancelled and every case passed |
TPdfBenchmarkReport.ToJson / ToCsv | Serialize the complete report to JSON or CSV text |
TPdfBenchmarkReport.SaveJsonToFile / SaveCsvToFile | Write the serialized report to a UTF-8 file |
RunPdfBenchmarkCorpus | Runs fully described benchmark cases with the requested options and cancellation token |
RunPdfBenchmarkFiles | Runs a list of file names using default case metadata and the requested options |
| Record | Public fields |
|---|---|
TPdfBenchmarkCase | Name, EnhancementId, FileName, Password, ExpectedSemanticHash, and ExpectedPixelHash |
TPdfBenchmarkOptions | WarmupRuns, MeasuredRuns, MaxPages, RenderWidth, RenderHeight, MaxPixelsPerPage, RenderOptions, BackgroundColor, IncludeSemanticHash, IncludePixelHash, VerifyIndependentReopen, MemorySampleIntervalMs, and StopOnFailure |
Each warm-up and measured pass opens a fresh TPdf instance from the case path, loads it through the normal PDFium-backed API, renders a bounded page subset, computes requested hashes, saves to memory, and releases every handle
The first-page metric combines document load and the first bounded page render so it represents time to first usable pixels rather than parser construction alone
Render throughput uses the measured page count and render duration while MaxPages, RenderWidth, RenderHeight, and MaxPixelsPerPage bound work before bitmap allocation
The semantic SHA-256 digest covers page order, page dimensions, rotations, and UTF-16 text while the pixel SHA-256 digest covers deterministic bitmap dimensions and scanline bytes
When independent reopen validation is enabled, the saved bytes are loaded into a second TPdf instance and the page count, semantic hash, and pixel hash must match the measured input pass
A case fails if hashes vary between measured runs, an expected hash does not match, independent reopen changes semantics or pixels, loading or saving fails, or a bounded operation raises an error
| Field | Meaning |
|---|---|
InputBytes / SavedBytes | Source file length and PDFium save output length |
LoadMilliseconds | Average measured document load duration |
FirstPageMilliseconds | Average load plus first bounded render duration |
RenderMilliseconds / RenderPagesPerSecond | Average bounded render duration and derived page throughput |
SaveMilliseconds / ReopenMilliseconds | Average in-memory save and independent reopen validation duration |
BaselineWorkingSetBytes / PeakWorkingSetBytes | Lowest baseline and highest sampled process working set across measured passes |
PeakWorkingSetIncreaseBytes | Largest sampled increase above the corresponding run baseline |
SemanticHash / PixelHash | Lowercase SHA-256 digests used for stability and corpus expectation gates |
ReopenSemanticHash / ReopenPixelHash | Identities computed from the independently reopened save |
StableAcrossRuns | True when every measured pass produces the same semantic and pixel identities |
IndependentReopenChecked / IndependentReopenSucceeded | Report whether reopen validation was requested and whether reopening succeeded |
EquivalentAfterReopen | True when the independently reopened save preserves page count and selected identities |
ExpectedSemanticHashMatched / ExpectedPixelHashMatched | Report each configured corpus expectation gate independently |
| Record | Public fields |
|---|---|
TPdfBenchmarkCaseResult | Name, EnhancementId, FileName, Status, ErrorText, PageCount, PagesRendered, WarmupRuns, and MeasuredRuns, in addition to the measurement and gate fields listed above |
TPdfBenchmarkReport | Results contains the ordered case results and Cancelled records terminal cancellation |
TPdfBenchmarkOptions.Default enables semantic and pixel hashes, independent reopen checks, one warm-up pass, three measured passes, and bounded renderingTPdfBenchmarkReport.IsConformant return 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;