123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs. <contact@nomadic-labs.com> *)(* Copyright (c) 2023 Marigold <contact@marigold.dev> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)openBenchmarks_shellletns=Namespace.makeShell_namespace.ns"bloomer"letfvs=Free_variable.of_namespace(nss)(* We use the same Bloom filter configuration as used in P2p_acl *)letconst_time_model~const_name~name=Model.make~conv:(fun()->())(Model.unknown_const1~name~const:(fvconst_name))letmake_bench~name~info~model~generator~make_bench:Benchmark.simple=letmoduleBench=structtypeconfig=unitletdefault_config=()letmodule_filename=__FILE__letpurpose=Benchmark.Other_purpose"Measuring the cost of bloom filter. Not used in the protocol."letconfig_encoding=Data_encoding.unittypeworkload=unitletworkload_encoding=Data_encoding.unitletworkload_to_vector()=Sparse_vec.String.of_list[("encoding",1.)]letname=nsnameletinfo=infolettags=["misc"]letgroup=Benchmark.Group"bloomer"letcreate_benchmark~rng_state_=letgenerator()=generatorrng_stateinmake_benchgeneratorletmodel=model~nameendin(moduleBench)letmake_bloomer()=Bloomer.create~hash:(funx->Tezos_crypto.Blake2B.(to_bytes(hash_string[x])))~hashes:5~countdown_bits:4~index_bits:(Bits.numbits(2*1024*8*1024/4))(* This is a feature of the peer-to-peer layer.
The benchmark is not used to generate values for the protocol. *)let()=Registration.register_simple@@make_bench~name:"bloomer_mem"~info:"Benchmarking Bloomer.mem"~model:(const_time_model~const_name:"bloomer_mem_const")~generator:(fun_rng_state->letbloomer=make_bloomer()inletstring="test"inBloomer.addbloomerstring;(bloomer,string))~make_bench:(fungenerator->letbloomer,string=generator()inletclosure()=ignore(Bloomer.membloomerstring)inGenerator.Plain{workload=();closure})(* This is a feature of the peer-to-peer layer.
The benchmark is not used to generate values for the protocol. *)let()=Registration.register_simple@@make_bench~name:"bloomer_add"~info:"Benchmarking Bloomer.add"~model:(const_time_model~const_name:"bloomer_add_const")~generator:(fun_rng_state->make_bloomer())~make_bench:(fungenerator->letbloomer=generator()inletclosure()=ignore(Bloomer.addbloomer"test")inGenerator.Plain{workload=();closure})