30 lines
744 B
Python
30 lines
744 B
Python
import json
|
|
|
|
DIRECTORY = []
|
|
with open("data/all.json", "r") as fp:
|
|
DIRECTORY = json.load(fp)
|
|
|
|
def generate_datafile(obj):
|
|
path = "data/" + obj["name"]
|
|
|
|
with open(path, 'r') as fp:
|
|
benchmark = json.load(fp)
|
|
|
|
for time in benchmark["results"][0]["times"]:
|
|
yield {
|
|
"author": obj["author"],
|
|
"lang": obj["lang"],
|
|
"time": time / obj["runs"],
|
|
}
|
|
|
|
def generate_day(day : int):
|
|
for part in [ 1, 2 ]:
|
|
for measurement in generate_puzzle(f"{day}-{part}"):
|
|
measurement["part"] = part
|
|
yield measurement
|
|
|
|
def generate_puzzle(puzzle : str):
|
|
for obj in DIRECTORY:
|
|
if puzzle in obj["puzzles"]:
|
|
yield from generate_datafile(obj)
|