Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

histogram

time.histogram

(title String, period option time.duration, max_recorded option time.duration, ignore_first u64, ignore_last u64)
:
Any
 is
time.histogram -- feature to collect and output timing data

This is particularly useful to analyse variations in release or
execution times of repeatedly executed tasks or events.

For this, it distributes time.duration values into a list of
buckets that correspond to different ranges of durations. These
buckets may be equally spaced (linear) or growing by an equal
factor (logarithmic).

The use of buckets permits the collection of large numbers of
sampe durations since only the counts per bucket are recorded

Fields

For measuring a periodic jitter, this gives the period.

If the period is given it becomes possible to detect drift,
i.e, the actual times are measured relative to the expected
times for given `period`. A cumulative drift, i.e., an actual
period that is slightly longer or shorter in average, will add
up to a significant jitter.

Note that periods like `1/60` cannot be traced accurately, the
rounding error in 16666666ns (or 16666667ns) will add up over
time!
the maximum duration that will be recorded in this histogram

if specified, the histogram will use a linear time scale from
0 up to max_recorded

if `nil`, the histogram will use a generic logarithmic time scale
from 1ns up to about 1day.
ignore_first
 u64
number of initial recordings that should be ignored (i.e.,
that are considered to be part of a _warm up_ phase).
ignore_last
 u64
number of final recordings that should be ignored. This permits
errors introduces by starting of the shutdown process to be
ignored.

Functions

record the given duration

if `ignore_first` or `ignore_last` are non-zero, this will ignore the
first or last records accordingly
record the given time instant, i.e., create the difference to the previous instant
and record that
 => 
String
[Redefinition of  Any.as_string]
Create a string with a graphical representation of this histogram.

redefines:

Determine the average value in this histogram or 0 in case there are
no recorded values.
number of measurements in this histogram.
Create semicolon-separated CSV data for these measurments to import into Excel or
OpenOffice. First lines will be descriptions.
 => 
Type
[Inherited from  Any]
Get the dynamic type of this instance. For value instances `x`, this is
equal to `type_of x`, but for `x` with a `ref` type `x.dynamic_type` gives
the actual runtime type, while `type_of x` results in the static
compile-time type.

There is no dynamic type of a type instance since this would result in an
endless hierarchy of types. So for Type values, dynamic_type is redefined
to just return Type.type.
Find the highest count recorded for this histogram, or 0 if no times were recorded.
Determine the maximum value in this histogram.
Determine the minimum value in this histogram.
 => 
String
[Inherited from  Any]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.
Determine the standard deviation from the average of the
difference of the values in this histogram to a given value m.
Determine the standard deviation of the difference of the recorded values
in this histogram to a given value m, result is 0 in case there are no
recorded values.

result is `time.duration.zero` if no measurements were made yet

Type Functions

 => 
String
[Inherited from  Type]
string representation of this type to be used for debugging.

result has the form "Type of '<name>'", but this might change in the future

redefines:

 => 
Type
[Inherited from  Type]
There is no dynamic type of a type instance since this would result in an
endless hierarchy of types, so dynamic_type is redefined to just return
Type.type here.

redefines:

(T 
type
:
Type)
 => 
bool
[Inherited from  Type]
Is this type assignable to a type parameter with constraint `T`?

The result of this is a compile-time constant that can be used to specialize
code for a particular type.


it is most useful in conjunction with preconditions or `if` statements as in


or

 => 
String
[Inherited from  Type]
name of this type, including type parameters, e.g. 'option (list i32)'.
Construct a new empty histogram for jitter
(title String, max_recorded option time.duration, ignore_first u64, ignore_last u64)
 => 
time.histogram
create an empty histogram
(title String, period option time.duration, max_recorded option time.duration, ignore_first u64, ignore_last u64)
 => 
time.histogram
Construct a new empty histogram for jitter on a known period using
 => 
String
[Inherited from  Type]
convenience prefix operator to create a string from a value.

This permits usage of `$` as a prefix operator in a similar way both
inside and outside of constant strings: $x and "$x" will produce the
same string.

NYI: Redefinition allows the type feature to be distinguished from its normal counterpart, see #3913

redefines:

 => 
Type
[Inherited from  Any]
Get a type as a value.

This is a feature with the effect equivalent to Fuzion's `expr.type` call tail.
It is recommended to use `expr.type` and not `expr.type_value`.

`type_value` is here to show how this can be implemented and to illustrate the
difference to `dynamic_type`.
0.095dev (2025-08-15 12:02:22 GIT hash 301b5b75e77076d091b38f555473f9f0e31e5b5c built by fridi@fzen)