package tezos-benchmark

  1. Overview
  2. Docs
type 'a sampler = Stdlib.Random.State.t -> 'a

The type of samplers. Samplers should be deterministic in their input. Note that a value of type Random.State.t is mutable and can be updated destructively at each call of the sampler.

type range = {
  1. min : int;
  2. max : int;
}

Range (inclusive)

val sample_in_interval : range:range -> int sampler

sample_in_interval ~range creates a sampler in the specified interval.

  • raises Invalid_argument

    if range.max < range.min.

val sample_float_in_interval : min:float -> max:float -> float sampler

sample_float_in_interval ~min ~max creates a sampler in the specified interval.

  • raises Invalid_argument

    if max <= min.

val uniform_bool : bool sampler

Samples a boolean uniformly at random

val uniform_byte : char sampler

Sample a byte uniformly at random

val uniform_partial_byte : nbits:int -> char sampler

Samples the specified number of bits uniformly at random. The sampled bits are the nbits least significant ones in the returned char.

  • raises Invalid_argument

    if nbits < 1 || nbits > 8.

val uniform_string : nbytes:int -> string sampler

Samples a string of length nbytes uniformly at random.

  • raises Invalid_argument

    if nbytes < 0.

val uniform_bytes : nbytes:int -> bytes sampler

Samples bytes of length nbytes uniformly at random.

  • raises Invalid_argument

    if nbytes < 0.

val uniform_nat : nbytes:int -> Z.t sampler

Samples a non-negative big integer stored on nbytes bytes, uniformly at random (modulo trailing zeroes).

  • raises Invalid_argument

    if nbytes < 0.

val uniform_int : nbytes:int -> Z.t sampler

Samples a big integer stored on nbytes bytes, uniformly at random (modulo trailing zeroes).

  • raises Invalid_argument

    if nbytes < 0.

val nat : size:range -> Z.t sampler

Samples a size in bytes uniformly in size and then samples a uniform non-negative big integer of this size.

  • raises Invalid_argument

    if size.max < size.min or if size.min < 0.

val int : size:range -> Z.t sampler

Samples a size in bytes uniformly in size and then samples a uniform big integer of this size.

  • raises Invalid_argument

    if size.max < size.min or if size.min < 0.

val uniform_readable_ascii : char sampler

Samples a readable character.

val readable_ascii_string : size:range -> string sampler

Samples a readable string with length sampled uniformly in size.

  • raises Invalid_argument

    if size.max < size.min or if range.min < 0.

val string : size:range -> string sampler

Samples a string with length sampled uniformly in size.

  • raises Invalid_argument

    if size.max < size.min or if size.min < 0.

val bytes : size:range -> bytes sampler

Samples bytes with length sampled uniformly in size.

  • raises Invalid_argument

    if size.max < size.min or if size.min < 0.

module Adversarial : sig ... end

Sampling of "adversarial" values in the sense that they exhibit the worst-case performance of the usual comparison functions.

OCaml

Innovation. Community. Security.