How to use the pyperf._runner.CLIError function in pyperf

To help you get started, we’ve selected a few pyperf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vstinner / pyperf / pyperf / _runner.py View on Github external
raise CLIError("--calibrate-warmups requires --loops=N")
        elif args.recalibrate_warmups:
            self._only_in_worker("--recalibrate-warmups")
            if args.loops < 1 or args.warmups is None:
                raise CLIError("--recalibrate-warmups requires "
                               "--loops=N and --warmups=N")
        else:
            if args.worker and args.loops < 1:
                raise CLIError("--worker requires --loops=N "
                               "or --calibrate-loops")
            if args.worker and args.warmups is None:
                raise CLIError("--worker requires --warmups=N "
                               "or --calibrate-warmups")

            if args.values < 1:
                raise CLIError("--values must be >= 1")

        filename = args.output
        if filename and os.path.exists(filename):
            raise CLIError("The JSON file %r already exists" % filename)

        if args.worker_task:
            self._only_in_worker("--worker-task")

        if args.tracemalloc:
            try:
                import tracemalloc   # noqa
            except ImportError as exc:
                raise CLIError("fail to import tracemalloc: %s" % exc)

        if args.track_memory:
            if MS_WINDOWS:
github vstinner / pyperf / pyperf / _runner.py View on Github external
raise CLIError("--recalibrate-loops requires --loops=N")
        elif args.calibrate_warmups:
            self._only_in_worker("--calibrate-warmups")
            if args.loops < 1:
                raise CLIError("--calibrate-warmups requires --loops=N")
        elif args.recalibrate_warmups:
            self._only_in_worker("--recalibrate-warmups")
            if args.loops < 1 or args.warmups is None:
                raise CLIError("--recalibrate-warmups requires "
                               "--loops=N and --warmups=N")
        else:
            if args.worker and args.loops < 1:
                raise CLIError("--worker requires --loops=N "
                               "or --calibrate-loops")
            if args.worker and args.warmups is None:
                raise CLIError("--worker requires --warmups=N "
                               "or --calibrate-warmups")

            if args.values < 1:
                raise CLIError("--values must be >= 1")

        filename = args.output
        if filename and os.path.exists(filename):
            raise CLIError("The JSON file %r already exists" % filename)

        if args.worker_task:
            self._only_in_worker("--worker-task")

        if args.tracemalloc:
            try:
                import tracemalloc   # noqa
            except ImportError as exc:
github vstinner / pyperf / pyperf / _runner.py View on Github external
raise CLIError("--recalibrate-warmups requires "
                               "--loops=N and --warmups=N")
        else:
            if args.worker and args.loops < 1:
                raise CLIError("--worker requires --loops=N "
                               "or --calibrate-loops")
            if args.worker and args.warmups is None:
                raise CLIError("--worker requires --warmups=N "
                               "or --calibrate-warmups")

            if args.values < 1:
                raise CLIError("--values must be >= 1")

        filename = args.output
        if filename and os.path.exists(filename):
            raise CLIError("The JSON file %r already exists" % filename)

        if args.worker_task:
            self._only_in_worker("--worker-task")

        if args.tracemalloc:
            try:
                import tracemalloc   # noqa
            except ImportError as exc:
                raise CLIError("fail to import tracemalloc: %s" % exc)

        if args.track_memory:
            if MS_WINDOWS:
                from pyperf._win_memory import check_tracking_memory
            else:
                from pyperf._memory import check_tracking_memory
            err_msg = check_tracking_memory()
github vstinner / pyperf / pyperf / _runner.py View on Github external
elif args.recalibrate_loops:
            self._only_in_worker("--recalibrate-loops")
            if args.loops < 1:
                raise CLIError("--recalibrate-loops requires --loops=N")
        elif args.calibrate_warmups:
            self._only_in_worker("--calibrate-warmups")
            if args.loops < 1:
                raise CLIError("--calibrate-warmups requires --loops=N")
        elif args.recalibrate_warmups:
            self._only_in_worker("--recalibrate-warmups")
            if args.loops < 1 or args.warmups is None:
                raise CLIError("--recalibrate-warmups requires "
                               "--loops=N and --warmups=N")
        else:
            if args.worker and args.loops < 1:
                raise CLIError("--worker requires --loops=N "
                               "or --calibrate-loops")
            if args.worker and args.warmups is None:
                raise CLIError("--worker requires --warmups=N "
                               "or --calibrate-warmups")

            if args.values < 1:
                raise CLIError("--values must be >= 1")

        filename = args.output
        if filename and os.path.exists(filename):
            raise CLIError("The JSON file %r already exists" % filename)

        if args.worker_task:
            self._only_in_worker("--worker-task")

        if args.tracemalloc:
github vstinner / pyperf / pyperf / _runner.py View on Github external
def _only_in_worker(self, option):
        if not self.args.worker:
            raise CLIError("option %s requires --worker" % option)
github vstinner / pyperf / pyperf / _runner.py View on Github external
self._only_in_worker("--worker-task")

        if args.tracemalloc:
            try:
                import tracemalloc   # noqa
            except ImportError as exc:
                raise CLIError("fail to import tracemalloc: %s" % exc)

        if args.track_memory:
            if MS_WINDOWS:
                from pyperf._win_memory import check_tracking_memory
            else:
                from pyperf._memory import check_tracking_memory
            err_msg = check_tracking_memory()
            if err_msg:
                raise CLIError("unable to track the memory usage "
                               "(--track-memory): %s" % err_msg)

        args.python = abs_executable(args.python)
        if args.compare_to:
            args.compare_to = abs_executable(args.compare_to)

        if args.compare_to:
            for option in ('output', 'append'):
                if getattr(args, option):
                    raise CLIError("--%s option is incompatible "
                                   "with --compare-to option" % option)
github vstinner / pyperf / pyperf / _runner.py View on Github external
self._only_in_worker("--calibrate-loops")
            if args.loops:
                raise CLIError("--loops=N is incompatible with "
                               "--calibrate-loops")
        elif args.recalibrate_loops:
            self._only_in_worker("--recalibrate-loops")
            if args.loops < 1:
                raise CLIError("--recalibrate-loops requires --loops=N")
        elif args.calibrate_warmups:
            self._only_in_worker("--calibrate-warmups")
            if args.loops < 1:
                raise CLIError("--calibrate-warmups requires --loops=N")
        elif args.recalibrate_warmups:
            self._only_in_worker("--recalibrate-warmups")
            if args.loops < 1 or args.warmups is None:
                raise CLIError("--recalibrate-warmups requires "
                               "--loops=N and --warmups=N")
        else:
            if args.worker and args.loops < 1:
                raise CLIError("--worker requires --loops=N "
                               "or --calibrate-loops")
            if args.worker and args.warmups is None:
                raise CLIError("--worker requires --warmups=N "
                               "or --calibrate-warmups")

            if args.values < 1:
                raise CLIError("--values must be >= 1")

        filename = args.output
        if filename and os.path.exists(filename):
            raise CLIError("The JSON file %r already exists" % filename)
github vstinner / pyperf / pyperf / _runner.py View on Github external
from pyperf._win_memory import check_tracking_memory
            else:
                from pyperf._memory import check_tracking_memory
            err_msg = check_tracking_memory()
            if err_msg:
                raise CLIError("unable to track the memory usage "
                               "(--track-memory): %s" % err_msg)

        args.python = abs_executable(args.python)
        if args.compare_to:
            args.compare_to = abs_executable(args.compare_to)

        if args.compare_to:
            for option in ('output', 'append'):
                if getattr(args, option):
                    raise CLIError("--%s option is incompatible "
                                   "with --compare-to option" % option)
github vstinner / pyperf / pyperf / _runner.py View on Github external
args.min_time = 1e-9

        # calibration
        if args.calibrate_loops:
            self._only_in_worker("--calibrate-loops")
            if args.loops:
                raise CLIError("--loops=N is incompatible with "
                               "--calibrate-loops")
        elif args.recalibrate_loops:
            self._only_in_worker("--recalibrate-loops")
            if args.loops < 1:
                raise CLIError("--recalibrate-loops requires --loops=N")
        elif args.calibrate_warmups:
            self._only_in_worker("--calibrate-warmups")
            if args.loops < 1:
                raise CLIError("--calibrate-warmups requires --loops=N")
        elif args.recalibrate_warmups:
            self._only_in_worker("--recalibrate-warmups")
            if args.loops < 1 or args.warmups is None:
                raise CLIError("--recalibrate-warmups requires "
                               "--loops=N and --warmups=N")
        else:
            if args.worker and args.loops < 1:
                raise CLIError("--worker requires --loops=N "
                               "or --calibrate-loops")
            if args.worker and args.warmups is None:
                raise CLIError("--worker requires --warmups=N "
                               "or --calibrate-warmups")

            if args.values < 1:
                raise CLIError("--values must be >= 1")