Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0938eae6 authored by GUILLEMOT Alexandre's avatar GUILLEMOT Alexandre
Browse files

add run_entries.py

parent 06190f1c
Branches
No related tags found
No related merge requests found
import argparse
import subprocess
import os
import glob
import json
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument(
"entries", help="The entry files that specifies what should be benchmarked")
parser.add_argument("-p", "--perf", action='store_true', default=False,
help="perf stat the benchmark and put the result in perflog.txt")
parser.add_argument("-t", "--timeout", nargs="?", const=300,
help="To run the benchmark with a timeout. Should be written as <number><unit> where <unit> may be nothing (this implicitely means seconds), s, m or h, e.g. 1h")
parser.add_argument("-m", "--mem", nargs="?", const=8,
help="Maximum amount of memory used for the different tests. Should be written as <number><unit> where <unit> may be nothing, K, M or G, e.g. 100M")
parser.add_argument("-n", action='store_true',
help="To only run benchmarks not previously done")
args = parser.parse_args()
# Recovering data
assert Path(args.entries), "Specify valid path"
entries_file = open(args.entries, "r")
try:
entries = json.load(entries_file)
data_list = entries["data_list"]
pkg_list = entries["packages"]
except:
entries_file.close()
print("Wrong file format")
exit(1)
for i, pkg_name in enumerate(pkg_list):
print(f"Package {i + 1}/{len(pkg_list)}")
for j, data_path in enumerate(data_list):
print(f"Data {j + 1}/{len(data_list)}")
pkg_path = (Path("packages") / Path(f"{pkg_name}")).with_suffix(".py")
data_name = Path(data_path)
print(data_name)
print(pkg_path)
print(data_name / pkg_name)
print(str(("data" / Path(data_path)).with_suffix(".json")))
if not ((data_name / pkg_name).exists() and args.n):
subprocess.run(["python3", "runtest.py", str(pkg_path), str(("data" / Path(data_path)).with_suffix(".json"))] + ["--timeout", str(args.timeout)]*(
args.timeout != None) + ["--mem", str(args.mem)]*(args.mem != None) + ["--perf"]*args.perf)
......@@ -18,8 +18,11 @@ args = parser.parse_args()
pkg_path = Path(args.pkg)
data_path = Path(args.data)
tmp_data_str = f"file {data_path} does not exist"
tmp_pkg_str = f"file {pkg_path} does not exist"
assert data_path.exists() and pkg_path.exists(), "Specify correct data and pkg file."
assert data_path.exists(), tmp_data_str
assert pkg_path.exists(), tmp_pkg_str
data = data_path.stem
pkg = pkg_path.stem
......@@ -27,7 +30,7 @@ pkg = pkg_path.stem
print(f"Benchmarking {pkg} on {data_path}" + args.perf*" (with perf stat)")
print("Creating benchmark folder...")
bench_path = (Path("benchmarks").joinpath(*data_path.with_suffix("").parts[1:]) / pkg_path.with_suffix(""))
bench_path = (Path("benchmarks").joinpath(*data_path.with_suffix("").parts[1:]) / pkg)
bench_path.mkdir(parents=True, exist_ok=True)
print("Generating script and command...")
......
......@@ -42,55 +42,118 @@
"newton/sumpowlin-6-3-5/1",
"newton/sumpowlin-8-3-5/1"
],
"packages": [
"homotopycontinuation",
"algpath",
"macaulay2"
],
"header": {
"val": "root",
"children":
[
{"val": "name", "children": []},
{"val": "dimension", "children": []},
{"val": "max deg", "children": []},
{"val": "paths", "children": []},
"children": [
{
"val": "name",
"children": []
},
{
"val": "dimension",
"children": []
},
{
"val": "max deg",
"children": []
},
{
"val": "paths",
"children": []
},
{
"val": "instructions",
"children":
[
{"val": "f", "children": []},
{"val": "df", "children": []}
"children": [
{
"val": "f",
"children": []
},
{
"val": "df",
"children": []
}
]
},
{
"val": "homotopycontinuation",
"children":
[
{"val": "failures", "children": []},
{"val": "medsteps", "children": []},
{"val": "maxsteps", "children": []},
{"val": "stepspersec", "children": []},
{"val": "tottime", "children": []}
"children": [
{
"val": "failures",
"children": []
},
{
"val": "medsteps",
"children": []
},
{
"val": "maxsteps",
"children": []
},
{
"val": "stepspersec",
"children": []
},
{
"val": "tottime",
"children": []
}
]
},
{
"val": "algpath",
"children":
[
{"val": "failures", "children": []},
{"val": "medsteps", "children": []},
{"val": "maxsteps", "children": []},
{"val": "stepspersec", "children": []},
{"val": "tottime", "children": []}
"children": [
{
"val": "failures",
"children": []
},
{
"val": "medsteps",
"children": []
},
{
"val": "maxsteps",
"children": []
},
{
"val": "stepspersec",
"children": []
},
{
"val": "tottime",
"children": []
}
]
},
{
"val": "macaulay2",
"children":
[
{"val": "failures", "children": []},
{"val": "medsteps", "children": []},
{"val": "maxsteps", "children": []},
{"val": "stepspersec", "children": []},
{"val": "tottime", "children": []}
"children": [
{
"val": "failures",
"children": []
},
{
"val": "medsteps",
"children": []
},
{
"val": "maxsteps",
"children": []
},
{
"val": "stepspersec",
"children": []
},
{
"val": "tottime",
"children": []
}
]
}
]
}
}
}
\ No newline at end of file
......@@ -2,6 +2,10 @@
"data_list": [
"linear/katsura-20/all/1"
],
"packages": [
"homotopycontinuation",
"algpath"
],
"header": {
"val": "root",
"children":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment