fn execute<M: Measurement + 'static>(
    c: &mut Criterion<M>,
    move_vm: &MoveVM,
    modules: Vec<CompiledModule>,
    fun: &str,
) {
    // establish running context
    let storage = BlankStorage::new();
    let sender = CORE_CODE_ADDRESS;
    let mut session = move_vm.new_session(&storage);
    let mut gas_status = GasStatus::new_unmetered();

    for module in modules {
        let mut mod_blob = vec![];
        module
            .serialize(&mut mod_blob)
            .expect("Module serialization error");
        session
            .publish_module(mod_blob, sender, &mut gas_status)
            .expect("Module must load");
    }

    // module and function to call
    let module_id = ModuleId::new(sender, Identifier::new("Bench").unwrap());
    let fun_name = IdentStr::new(fun).unwrap_or_else(|_| panic!("Invalid identifier name {}", fun));

    // benchmark
    c.bench_function(fun, |b| {
        b.iter(|| {
            session
                .execute_function_bypass_visibility(
                    &module_id,
                    fun_name,
                    vec![],
                    Vec::<Vec<u8>>::new(),
                    &mut gas_status,
                )
                .unwrap_or_else(|err| {
                    panic!(
                        "{:?}::{} failed with {:?}",
                        &module_id,
                        fun,
                        err.into_vm_status()
                    )
                })
        })
    });
}
// execute a given function in the Bench module
execute a given function in the Bench module
execute a given function in the Bench module
fn execute<M: Measurement + 'static>(
    c: &mut Criterion<M>,
    move_vm: &MoveVM,
    modules: Vec<CompiledModule>,
    fun: &str,
) {
    // establish running context
    let storage = BlankStorage::new();
    let sender = CORE_CODE_ADDRESS;
    let mut session = move_vm.new_session(&storage);
    let mut gas_status = GasStatus::new_unmetered();
    for module in modules {
        let mut mod_blob = vec![];
        module
            .serialize(&mut mod_blob)
            .expect("Module serialization error");
        session
            .publish_module(mod_blob, sender, &mut gas_status)
            .expect("Module must load");
    }
    // module and function to call
    let module_id = ModuleId::new(sender, Identifier::new("Bench").unwrap());
    let fun_name = IdentStr::new(fun).unwrap_or_else(|_| panic!("Invalid identifier name {}", fun));
    // benchmark
    c.bench_function(fun, |b| {
        b.iter(|| {
            session
                .execute_function_bypass_visibility(
                    &module_id,
                    fun_name,
                    vec![],
                    Vec::<Vec<u8>>::new(),
                    &mut gas_status,
                )
                .unwrap_or_else(|err| {
                    panic!(
                        "{:?}::{} failed with {:?}",
                        &module_id,
                        fun,
                        err.into_vm_status()
                    )
                })
        })
    });
}
fn execute < M : Measurement + ' static > ( c : & mut Criterion < M > , move_vm : & MoveVM , modules : Vec < CompiledModule > , fun : & str , ) { // establish running context let storage = BlankStorage :: new ( ) ; let sender = CORE_CODE_ADDRESS ; let mut session = move_vm . new_session ( & storage ) ; let mut gas_status = GasStatus :: new_unmetered ( ) ; for module in modules { let mut mod_blob = vec ! [ ] ; module . serialize ( & mut mod_blob ) . expect ( " " ) ; session . publish_module ( mod_blob , sender , & mut gas_status ) . expect ( " " ) ; } // module and function to call let module_id = ModuleId :: new ( sender , Identifier :: new ( " " ) . unwrap ( ) ) ; let fun_name = IdentStr :: new ( fun ) . unwrap_or_else ( | _ | panic ! ( " " fun ) ) ; // benchmark c . bench_function ( fun , | b | { b . iter ( | | { session . execute_function_bypass_visibility ( & module_id , fun_name , vec ! [ ] , Vec :: < Vec < u8 > > :: new ( ) , & mut gas_status , ) . unwrap_or_else ( | err | { panic ! ( " " module_id fun err into_vm_status ( ) ) } ) } ) } ) ; }
execute a given function in the Bench module
execute a given function in the Bench module
c
&mut Criterion<M>
move_vm
&MoveVM
modules
Vec<CompiledModule>
fun
&str