Tezos_benchmark.Modelval arity_0 : ('elt, 'elt, unit) arityval arity_1 : ('elt, 'elt -> 'elt, int * unit) arityval arity_2 : ('elt, 'elt -> 'elt -> 'elt, int * (int * unit)) arityval arity_3 :
('elt, 'elt -> 'elt -> 'elt -> 'elt, int * (int * (int * unit))) aritymodule type Model_impl = sig ... endAbstract representation of models. Models are strongly typed: Model_impl.arg_type exposes what a model expects on input. The relation between arg_type and model_type is encoded through a value of type arity.
type 'arg model = (module Model_impl with type arg_type = 'arg)module type Instantiated = sig ... endInstantiation of a Model_impl.Def with a Costlang.S
module Instantiate
(X : Costlang.S)
(M : Model_impl) :
Instantiated
with type 'a repr = 'a X.repr
and type size = X.size
and type arg_type = M.arg_typemodule type Applied = functor (X : Costlang.S) -> sig ... endModel that has been applied to some arguments. Typically, we get an Applied model when we apply some workload from a benchmark to its model. Can be obtained with apply.
type applied = (module Applied)type 'workload t = | Abstract : {conv : 'workload -> 'arg;model : 'arg model;} -> 'workload t| Aggregate : {model : 'workload -> applied;sub_models : packed_model list;} -> 'workload tModel containers for benchmarks. We distinguish two kinds:
'arg model, with a conv function that transforms a benchmark's workload into the model's arguments.sub_models.val pp : Stdlib.Format.formatter -> _ t -> unitBuild _ t from _ model, with a type conversion fucntion conv. If ~takes_saturation_reprs: true is given, its generated code will take _ Saturation_reprs.t instead of int.
val make_aggregated :
model:('a -> applied) ->
sub_models:packed_model list ->
'a tapply takes a model and an appropriate workload, and returns an applied model
Addition on models. Note that the results is always an Aggregate
val get_free_variable_set : _ model -> Free_variable.Set.tReturns the set of free variables of a model
val get_free_variable_set_of_t : _ t -> Free_variable.Set.tval get_free_variable_set_applied :
'workload t ->
'workload ->
Free_variable.Set.tReturns the set of free variables of an applied model
Note that this can be very different from get_free_variable_set.
Commonly used abstract models Except for zero, they all require a unique name in Namespace.t, and some Free_variable.ts. Those free are deduced during the inference in Snoop, and the resulting values are (usually) the gas parameters for the protocol.
val zero : unit modelzero is the "zero" for the addition on models. It can be seen as the model of the empty code. fun () -> 0
val unknown_const1 : name:Namespace.t -> const:Free_variable.t -> unit modelModel for code that executes in constant time fun () -> const
val unknown_const1_skip1 :
name:Namespace.t ->
const:Free_variable.t ->
(int * unit) modelModel ignores the arguments. fun n -> const
val unknown_const1_skip2 :
name:Namespace.t ->
const:Free_variable.t ->
(int * (int * unit)) modelModel ignores the arguments. fun n m -> const
val linear : name:Namespace.t -> coeff:Free_variable.t -> (int * unit) modelfun n -> coeff × n
val affine :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * unit) modelfun n -> intercept + coeff × n
val affine_offset :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
offset:int ->
(int * unit) modelfun n -> intercept + coeff × (n - offset)
val quadratic : name:Namespace.t -> coeff:Free_variable.t -> (int * unit) modelfun n -> coeff * n²
val nlogn :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * unit) modelfun n -> intercept + coeff × n×log(n)
val nsqrtn_const :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * unit) modelfun n -> intercept + coeff × n×sqrt(n)
val logn : name:Namespace.t -> coeff:Free_variable.t -> (int * unit) modelfun n -> coeff * log(n)
val linear_sum :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × (a+b)
val linear_sat_sub :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × (a-b)
val linear_max :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × max(a,b)
val linear_min :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × min(a,b)
val linear_min_offset :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
offset:int ->
(int * (int * unit)) modelfun a b -> intercept + coeff × (min(a,b) - offset)
val linear_mul :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × (a×b)
val bilinear :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
(int * (int * unit)) modelfun a b -> coeff1 × a + coeff2 × b
val bilinear_affine :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff1 × a + coeff2 × b
val affine_skip1 :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun a b -> intercept + coeff × b
val nlogm :
name:Namespace.t ->
intercept:Free_variable.t ->
coeff:Free_variable.t ->
(int * (int * unit)) modelfun n m -> intercept + coeff × n×log(m)
val n_plus_logm :
name:Namespace.t ->
intercept:Free_variable.t ->
linear_coeff:Free_variable.t ->
log_coeff:Free_variable.t ->
(int * (int * unit)) modelfun n m -> intercept + (linear_coeff × n) + (log_coeff × log(m))
val trilinear :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
coeff3:Free_variable.t ->
(int * (int * (int * unit))) modelfun a b c -> coeff1 × a + coeff2 × b + coeff3 × c
val breakdown :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
break:int ->
(int * unit) modelA multi-affine model in two parts. The breakpoint break indicates the point at which the slope changes coefficient.
val breakdown2 :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
coeff3:Free_variable.t ->
break1:int ->
break2:int ->
(int * unit) modelA multi-affine model in three parts, with breakpoints break1 and break2. Expects break1 <= break2
val breakdown2_const :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
coeff3:Free_variable.t ->
const:Free_variable.t ->
break1:int ->
break2:int ->
(int * unit) modelbreakdown2 with a non-zero value at 0
val breakdown2_const_offset :
name:Namespace.t ->
coeff1:Free_variable.t ->
coeff2:Free_variable.t ->
coeff3:Free_variable.t ->
const:Free_variable.t ->
break1:int ->
break2:int ->
offset:int ->
(int * unit) modelbreakdown2 with a non-zero value at 0 and offset
module type Binary_operation = sig ... endval synthesize :
name:Namespace.t ->
binop:(module Binary_operation) ->
x_label:string ->
x_model:'a model ->
y_label:string ->
y_model:'a model ->
'a modelSynthesize two models of the same signature by the specified binary operation.