Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:
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:
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()
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:
def _only_in_worker(self, option):
if not self.args.worker:
raise CLIError("option %s requires --worker" % option)
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)
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)
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)
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")