def METHOD_NAME(test, params, env):
    """
    Test virsh save with different formats and compare duration and image size
    """
    vm_name = params.get('main_vm')
    vm = env.get_vm(vm_name)
    status_error = "yes" == params.get('status_error', 'no')
    error_msg = params.get('error_msg', '')
    vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
    bkxml = vmxml.copy()
    save_formats = params.get('save_formats', '').split()
    rand_id = '_' + utils_misc.generate_random_string(3)
    save_path = f'/var/tmp/{vm_name}_{rand_id}.save'
    check_cmd = params.get('check_cmd', '')
    check_cmd = check_cmd.format(save_path) if check_cmd else check_cmd
    try:
        vm.start()
        if not status_error:
            save_info = {}
            for save_format in save_formats:
                save_info[save_format] = save_with_format(save_format, test,
                                                          params, env)
            [LOG.debug(f"Duration of format {f} is {save_info[f]['duration']}")
             for f in save_formats]
            [LOG.debug(f"Image size of format {f} is {save_info[f]['img_size']}"
                       ) for f in save_formats]
            duration_list = [save_info[f]['duration'] for f in save_formats]
            if sorted(duration_list) != duration_list:
                test.fail(
                    'The order of time cost is not correct, please check log')
            img_size_list = [save_info[f]['img_size'] for f in save_formats]
            if sorted(img_size_list, reverse=True) != img_size_list:
                test.fail(
                    'The order of image size is not correct, please check log')
        else:
            save_format = params.get('save_format')
            qemu_conf = utils_config.LibvirtQemuConfig()
            libvirtd = utils_libvirtd.Libvirtd()
            qemu_conf.save_image_format = save_format
            libvirtd.restart()
            save_result = virsh.save(vm_name, save_path, debug=True)
            libvirt.check_result(save_result, error_msg)
    finally:
        bkxml.sync()
        if 'qemu_conf' in locals():
            qemu_conf.restore()
            libvirtd.restart()
        if os.path.exists(save_path):
            os.remove(save_path)