Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return self.hold()
elif i.control & 1 == 0:
i.control //= 2
return self.release(I_DEVA)
else:
i.control = i.control // 2 ^ 0xd008
return self.release(I_DEVB)
# WorkTask
A = ord('A')
class WorkTask(Task):
def __init__(self, i, p, w, s, r):
Task.__init__(self, i, p, w, s, r)
def fn(self, pkt, r):
w = r
assert isinstance(w, WorkerTaskRec)
if pkt is None:
return self.waitTask()
if w.destination == I_HANDLERA:
dest = I_HANDLERB
else:
dest = I_HANDLERA
w.destination = dest
h.work_in = work.link
return self.qpkt(work)
dev = h.device_in
if dev is None:
return self.waitTask()
h.device_in = dev.link
dev.datum = work.data[count]
work.datum = count + 1
return self.qpkt(dev)
# IdleTask
class IdleTask(Task):
def __init__(self, i, p, w, s, r):
Task.__init__(self, i, 0, None, s, r)
def fn(self, pkt, r):
i = r
assert isinstance(i, IdleTaskRec)
i.count -= 1
if i.count == 0:
return self.hold()
elif i.control & 1 == 0:
i.control //= 2
return self.release(I_DEVA)
else:
i.control = i.control // 2 ^ 0xd008
return self.release(I_DEVB)
def projection_test(n):
"""
This test constructs a two sets of variables related to each
other by a simple linear transformation (scale and offset). The
time is measured to change a variable on either side of the
mapping and to change the scale and offset factors.
"""
global planner
planner = Planner()
scale = Variable("scale", 10)
offset = Variable("offset", 1000)
src = None
dests = OrderedCollection()
for i in range(n):
src = Variable("src%s" % i, i)
dst = Variable("dst%s" % i, i)
dests.append(dst)
StayConstraint(src, Strength.NORMAL)
ScaleConstraint(src, scale, offset, dst, Strength.REQUIRED)
change(src, 17)
if dst.value != 1170:
print("Projection 1 failed")
change(dst, 1050)
if src.value != 5:
def projection_test(n):
"""
This test constructs a two sets of variables related to each
other by a simple linear transformation (scale and offset). The
time is measured to change a variable on either side of the
mapping and to change the scale and offset factors.
"""
global planner
planner = Planner()
scale = Variable("scale", 10)
offset = Variable("offset", 1000)
src = None
dests = OrderedCollection()
for i in range(n):
src = Variable("src%s" % i, i)
dst = Variable("dst%s" % i, i)
dests.append(dst)
StayConstraint(src, Strength.NORMAL)
ScaleConstraint(src, scale, offset, dst, Strength.REQUIRED)
change(src, 17)
if dst.value != 1170:
print("Projection 1 failed")
def projection_test(n):
"""
This test constructs a two sets of variables related to each
other by a simple linear transformation (scale and offset). The
time is measured to change a variable on either side of the
mapping and to change the scale and offset factors.
"""
global planner
planner = Planner()
scale = Variable("scale", 10)
offset = Variable("offset", 1000)
src = None
dests = OrderedCollection()
for i in range(n):
src = Variable("src%s" % i, i)
dst = Variable("dst%s" % i, i)
dests.append(dst)
StayConstraint(src, Strength.NORMAL)
ScaleConstraint(src, scale, offset, dst, Strength.REQUIRED)
change(src, 17)
if dst.value != 1170:
print("Projection 1 failed")
def cmd_run(parser, options):
logging.basicConfig(level=logging.INFO)
print("Python benchmark suite %s" % pyperformance.__version__)
print()
if options.output and os.path.exists(options.output):
print("ERROR: the output file %s already exists!" % options.output)
sys.exit(1)
if hasattr(options, 'python'):
executable = options.python
else:
executable = sys.executable
if not os.path.isabs(executable):
print("ERROR: \"%s\" is not an absolute path" % executable)
sys.exit(1)
bench_funcs, bench_groups, should_run = get_benchmarks_to_run(options)
cmd_prefix = [executable]
suite, errors = run_benchmarks(bench_funcs, should_run, cmd_prefix, options)
implementation = sys.implementation.name.lower()
if not isinstance(data, bytes):
data = data.encode('utf-8')
with open(requirements, 'rb') as fp:
data += fp.read()
sha1 = hashlib.sha1(data).hexdigest()
name = ('%s%s.%s-%s'
% (implementation, pyver.major, pyver.minor, sha1[:12]))
print(name)
""")
requirements = os.path.join(PERFORMANCE_ROOT, 'requirements.txt')
cmd = (self.python, '-c', script,
pyperformance.__version__, requirements)
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
universal_newlines=True)
stdout = proc.communicate()[0]
if proc.returncode:
print("ERROR: failed to create the name of the virtual environment")
sys.exit(1)
venv_name = stdout.rstrip()
self._venv_path = venv_path = os.path.join('venv', venv_name)
return venv_path
def BM_python_startup_no_site(python, options):
return run_perf_script(python, options, "python_startup",
extra_args=["--no-site"])
def BM_genshi(python, options):
return run_perf_script(python, options, "genshi")
def BM_json_loads(python, options):
return run_perf_script(python, options, "json_loads")