2020-12-15 10:24:48 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2020-12-15 10:24:50 -06:00
|
|
|
import argparse
|
2020-12-15 10:24:48 -06:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
2020-12-15 10:24:50 -06:00
|
|
|
def gather_name(args):
|
|
|
|
if args.name:
|
|
|
|
return args.name
|
|
|
|
|
2020-12-15 10:24:49 -06:00
|
|
|
with open("/proc/cpuinfo", "rt") as f:
|
|
|
|
for line in f.readlines():
|
|
|
|
if line.startswith("model name"):
|
|
|
|
return line.split(":", 2)[1].strip()
|
|
|
|
|
2020-12-15 10:24:50 -06:00
|
|
|
exit("Error: '/proc/cpuinfo' does not contain a model name.\n"
|
|
|
|
"Use '--model' to set a model name.")
|
2020-12-15 10:24:49 -06:00
|
|
|
|
|
|
|
|
2020-12-15 10:24:48 -06:00
|
|
|
def main():
|
2020-12-15 10:24:50 -06:00
|
|
|
parser = argparse.ArgumentParser(description="Gather cpu test data")
|
|
|
|
parser.add_argument(
|
|
|
|
"--name",
|
|
|
|
help="CPU model name. "
|
|
|
|
"If unset, model name is read from '/proc/cpuinfo'.")
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
name = gather_name(args)
|
2020-12-15 10:24:49 -06:00
|
|
|
print("model name\t: {}".format(name))
|
|
|
|
|
|
|
|
print(end="", flush=True)
|
2020-12-15 10:24:48 -06:00
|
|
|
os.environ["CPU_GATHER_PY"] = "true"
|
|
|
|
subprocess.check_call("./cpu-gather.sh")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|