Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/scripts/performance/benchmark-mv
1566 views
#!/usr/bin/env python
from benchmark_utils import backup, copy, clean, get_default_argparser
from benchmark_utils import create_random_subfolder, benchmark_command
from benchmark_utils import get_transfer_command


def benchmark_mv(args):
    destination = args.destination
    if args.recursive:
        destination = create_random_subfolder(destination)
    command = 'mv %s %s' % (args.source, destination)
    command = get_transfer_command(command, args.recursive, args.quiet)
    backup_path = backup(args.source, args.recursive)

    def cleanup():
        if not args.no_cleanup:
            clean(destination, args.recursive)
        clean(backup_path, args.recursive)

    def upkeep():
        clean(args.source, args.recursive)
        copy(backup_path, args.source, args.recursive)

    benchmark_command(
        command, args.benchmark_script,  args.summarize_script,
        args.result_dir, args.num_iterations, args.dry_run,
        upkeep=upkeep,
        cleanup=cleanup
    )


if __name__ == "__main__":
    parser = get_default_argparser()
    parser.add_argument(
        '-s', '--source', required=True,
        help='A local path or s3 path.'
    )
    parser.add_argument(
        '-d', '--destination', required=True,
        help='A local path or s3 path. A directory will be created in this '
             'location to move to in the case of a recursive transfer.'
    )
    benchmark_mv(parser.parse_args())