PDFium Delphi Component Docs

FPdfBenchmark unit

Unit: FPdfBenchmark
Runs repeatable PDF performance measurements and conformance gates without sharing document, page, form or bitmap handles between passes

Syntax

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;

Public Types

TypeDescription
TPdfBenchmarkStatusTerminal state with pbsPassed, pbsFailed or pbsSkipped
TPdfBenchmarkCaseInput path, optional password, enhancement identifier, display name and optional expected semantic and pixel hashes
TPdfBenchmarkCasesDynamic array of TPdfBenchmarkCase values
TPdfBenchmarkOptionsWarm-up and measured pass counts, page and pixel budgets, rendering options, hash selection, independent reopen gate, sampling interval, cancellation and failure policy
TPdfBenchmarkCaseResultOne case result with byte sizes, page counts, timings, throughput, working-set samples, hashes, stability gates, reopen gates and failure evidence
TPdfBenchmarkCaseResultsDynamic array of TPdfBenchmarkCaseResult values
TPdfBenchmarkReportOrdered case results with aggregate counters, conformance status, JSON export, and CSV export

Functions and Record Methods

MemberDescription
PdfBenchmarkStatusNameReturns the stable display name for a TPdfBenchmarkStatus value
TPdfBenchmarkCase.FromFileCreates a case from a file path with optional enhancement identifier and display name
TPdfBenchmarkOptions.DefaultReturns bounded defaults for warm-up, measurement, rendering, hashing, reopen validation and memory sampling
TPdfBenchmarkCaseResult.IsPassedReturns True when the case status is pbsPassed
TPdfBenchmarkReport.PassedCount / FailedCount / SkippedCountCount results by terminal status
TPdfBenchmarkReport.IsConformantReturns True only when the run was not cancelled and every case passed
TPdfBenchmarkReport.ToJson / ToCsvSerialise the complete report to JSON or CSV text
TPdfBenchmarkReport.SaveJsonToFile / SaveCsvToFileWrite the serialised report to a UTF-8 file
RunPdfBenchmarkCorpusRuns fully described benchmark cases with the requested options and cancellation token
RunPdfBenchmarkFilesRuns a list of file names using default case metadata and the requested options

Case and Option Fields

RecordPublic fields
TPdfBenchmarkCaseName, EnhancementId, FileName, Password, ExpectedSemanticHash and ExpectedPixelHash
TPdfBenchmarkOptionsWarmupRuns, MeasuredRuns, MaxPages, RenderWidth, RenderHeight, MaxPixelsPerPage, RenderOptions, BackgroundColor, IncludeSemanticHash, IncludePixelHash, VerifyIndependentReopen, MemorySampleIntervalMs and StopOnFailure

Measurement Model

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 whilst 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 whilst 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

Result Fields

FieldMeaning
InputBytes / SavedBytesSource file length and PDFium save output length
LoadMillisecondsAverage measured document load duration
FirstPageMillisecondsAverage load plus first bounded render duration
RenderMilliseconds / RenderPagesPerSecondAverage bounded render duration and derived page throughput
SaveMilliseconds / ReopenMillisecondsAverage in-memory save and independent reopen validation duration
BaselineWorkingSetBytes / PeakWorkingSetBytesLowest baseline and highest sampled process working set across measured passes
PeakWorkingSetIncreaseBytesLargest sampled increase above the corresponding run baseline
SemanticHash / PixelHashLowercase SHA-256 digests used for stability and corpus expectation gates
ReopenSemanticHash / ReopenPixelHashIdentities computed from the independently reopened save
StableAcrossRunsTrue when every measured pass produces the same semantic and pixel identities
IndependentReopenChecked / IndependentReopenSucceededReport whether reopen validation was requested and whether reopening succeeded
EquivalentAfterReopenTrue when the independently reopened save preserves page count and selected identities
ExpectedSemanticHashMatched / ExpectedPixelHashMatchedReport each configured corpus expectation gate independently

Report and Result Identity Fields

RecordPublic fields
TPdfBenchmarkCaseResultName, EnhancementId, FileName, Status, ErrorText, PageCount, PagesRendered, WarmupRuns and MeasuredRuns, in addition to the measurement and gate fields listed above
TPdfBenchmarkReportResults contains the ordered case results and Cancelled records terminal cancellation

Remarks

Example

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;