gen_incl lower_bound upper_bound produces values between lower_bound and upper_bound, inclusive. It uses an ad hoc distribution that stresses boundary conditions more often than a uniform distribution, while still able to produce any value in the range. Raises if lower_bound > upper_bound.
gen_uniform_incl lower_bound upper_bound produces a generator for values uniformly distributed between lower_bound and upper_bound, inclusive. Raises if lower_bound > upper_bound.
Time spans are denominated as a float suffixed by a unit of time; the valid suffixes are listed below:
d - days h - hours m - minutes s - seconds ms - milliseconds us - microseconds ns - nanoseconds
to_string and sexp_of_t use a mixed-unit format, which breaks the input span into parts and concatenates them in descending order of unit size. For example, pi days is rendered as "3d3h23m53.60527015815s". If the span is negative, a single "-" precedes the entire string. For extremely large (>10^15 days) or small (<1us) spans, a unit may be repeated to ensure the string conversion round-trips.
of_string and t_of_sexp accept any combination of (nonnegative float string)(unit of time suffix) in any order, without spaces, and sums up the durations of each of the parts for the magnitude of the span. The input may be prefixed by "-" for negative spans.
String and sexp conversions round-trip precisely, that is:
to_int63_seconds_round_down_exn t returns the number of seconds represented by t, rounded down, raising if the result is not representable as an Int63.t.
The only condition to_proportional_float is supposed to satisfy is that for all t1, t2 : t: to_proportional_float t1 /. to_proportional_float t2 = t1 // t2.
Basic operations on spans
The arithmetic operations rely on the behavior of the underlying representation of a span. For example, if addition overflows with float-represented spans, the result is an infinite span; with fixed-width integer-represented spans, the result silently wraps around as in two's-complement arithmetic.
to_short_string t pretty-prints approximate time span using no more than five characters if the span is positive, and six if the span is negative. Examples
of_unit_of_time unit_of_time produces a t representing the corresponding span.
val to_string_hum :
?delimiter:Base.Char.t ->?decimals:Base.Int.t ->?align_decimal:Base.Bool.t ->?unit_of_time:Unit_of_time.t->t->Base.String.t
to_string_hum t ~delimiter ~decimals ~align_decimal ~unit_of_time formats t using the given unit of time, or the largest appropriate units if none is specified, among "d"=day, "h"=hour, "m"=minute, "s"=second, "ms"=millisecond, "us"=microsecond, or "ns"=nanosecond. The magnitude of the time span in the chosen unit is formatted by:
If align_decimal is true, the single-character suffixes are padded with an extra space character. In combination with not stripping zeroes, this means that the decimal point will occur a fixed number of characters from the end of the string.
val randomize :
?state:Core__.Import.Random.State.t ->t->percent:Percent.t->t
randomize t ~percent returns a span +/- percent * original span. Percent must be between 0% and 100% inclusive, and must be positive.
val of_sec_with_microsecond_precision : Base.Float.t ->t
deprecated [since 2019-01] use [of_span_float_round_nearest] or [of_span_float_round_nearest_microsecond]
*_round_nearest vs *_round_nearest_microsecond: If you don't know that you need microsecond precision, use the *_round_nearest version. *_round_nearest_microsecond is for historical purposes.
Span.Option.t is like Span.t option, except that the value is immediate on architectures where Int63.t is immediate. This module should mainly be used to avoid allocations.