\Drupal\strata\Codec CodecMeasurement

One measured compression result.

A value object rather than an array so the settings form cannot render a ratio where it meant a throughput, and so a reference figure and a figure measured on this site carry the same shape.

Summary

Methods
Properties
Constants
__construct
percentOfOriginal
megabytesPerGigabyte
secondsFor
jsonSerialize
codec
level
dictionary
frameSize
ratio
compressMbPerSecond
decompressMbPerSecond
onThisHost
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Properties

$codec

$codec : string

Type

string

$level

$level : int

Type

int

$dictionary

$dictionary : bool

Type

bool

$frameSize

$frameSize : int

Type

int

$ratio

$ratio : float

Type

float

$compressMbPerSecond

$compressMbPerSecond : float

Type

float

$decompressMbPerSecond

$decompressMbPerSecond : float

Type

float

$onThisHost

$onThisHost : bool

Type

bool

Methods

__construct()

__construct(string  $codec, int  $level, bool  $dictionary, int  $frameSize, float  $ratio, float  $compressMbPerSecond, float  $decompressMbPerSecond = 0.0, bool  $onThisHost = false) : mixed

Constructs a measurement.

Parameters

string $codec

The codec id the figures belong to.

int $level

The compression level used.

bool $dictionary

Whether a trained dictionary was supplied.

int $frameSize

Frame size in bytes the figures were taken at. Ratio moves with this, so a figure without it is not comparable to anything.

float $ratio

Uncompressed bytes divided by compressed bytes. Higher is smaller output.

float $compressMbPerSecond

Compression throughput.

float $decompressMbPerSecond

Decompression throughput, or 0.0 when it was not measured.

bool $onThisHost

TRUE when these figures were measured here, FALSE when they are the shipped reference.

Throws

\InvalidArgumentException

When a figure is negative or a ratio is below 1.0, either of which means the measurement itself failed rather than the codec performing badly.

Returns

mixed —

percentOfOriginal()

percentOfOriginal() : float

Percentage of the original size the output takes.

The form most people read faster than a ratio: 4.0x is "25% of the original".

Returns

float —

A percentage between 0 and 100.

megabytesPerGigabyte()

megabytesPerGigabyte() : float

Bytes stored per gigabyte of input, at this ratio.

Returns

float —

Megabytes stored per gigabyte captured.

secondsFor()

secondsFor(int  $bytes) : float

How long compressing a given volume takes at this throughput.

Parameters

int $bytes

Volume to compress.

Returns

float —

Seconds, or INF when throughput was measured as zero.

jsonSerialize()

jsonSerialize() : array<string,mixed>

{@inheritdoc}

Returns

array

The measurement as a plain array for a render array or a JSON response.