Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cpus = args.affinity
if cpus:
if not set_cpu_affinity(cpus):
print("ERROR: failed to set the CPU affinity")
sys.exit(1)
else:
cpus = get_isolated_cpus()
if cpus:
set_cpu_affinity(cpus)
# ignore if set_cpu_affinity() failed
run = pyperf.Run([1.0])
metadata = run.get_metadata()
if metadata:
print("Metadata:")
for line in format_metadata(metadata):
print(line)
if filename:
run = run._update_metadata({'name': 'metadata'})
bench = pyperf.Benchmark([run])
bench.dump(filename)
def _display_common_metadata(metadatas, lines):
if len(metadatas) < 2:
return
for metadata in metadatas:
# don't display name as metadata, it's already displayed
metadata.pop('name', None)
common_metadata = _common_metadata(metadatas)
if common_metadata:
format_title('Common metadata', lines=lines)
empty_line(lines)
format_metadata(common_metadata, lines=lines)
for key in common_metadata:
for metadata in metadatas:
metadata.pop(key, None)
if use_title:
show_filename = (data.get_nsuite() > 1)
show_name = not data.has_same_unique_benchmark()
if not show_filename and stats:
show_filename = (len(data) > 1)
suite = None
for index, item in enumerate(data):
lines = []
if show_metadata:
metadata = metadatas[index]
if metadata:
empty_line(lines)
lines.append("Metadata:")
format_metadata(metadata, lines=lines)
bench_lines = format_benchmark(item.benchmark,
hist=hist,
stats=stats,
dump=dump,
checks=checks,
result=result,
display_runs_args=display_runs_args)
if bench_lines:
empty_line(lines)
lines.extend(bench_lines)
if lines:
bench_lines = lines
lines = []