def _instancecheck_impl(self, value, info: Info = NoInfo()):
if not isinstance(value, List(Str())):
return info.errormsg(self)
if not is_perf_available():
return info.wrap(True)
assert isinstance(value, list)
if "wall-clock" in value:
value = value.copy()
value.remove("wall-clock")
cmd = "perf stat -x ';' -e {props} -- /bin/echo".format(props=",".join(value))
proc = subprocess.Popen(["/bin/sh", "-c", cmd], stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE, universal_newlines=True)
out, err = proc.communicate()
if proc.poll() > 0:
return info.errormsg(self, "Not a valid properties list: " + str(err).split("\n")[0].strip())
return info.wrap(True)
评论列表
文章目录