diff --git a/web/README.md b/web/README.md index 2a8ec62..0a51480 100644 --- a/web/README.md +++ b/web/README.md @@ -15,6 +15,9 @@ which runs benchmarks on a dedicated server with various GPU models. - GPU (Intel, release template) - GPU (NVIDIA, release template) --> +- The produced results (as .json or .md) should be copied into the `src-data/benchmarks` folder. +- The [./generate-content.py script](./generate-content.py) produces `.md` files + in the `content` folder, so that web pages can be generated for each graph and each benchmark. - [Hugo](https://gohugo.io/) is used to create a homepage listing recent benchmarked commits, plus a single page per engine commit. This allows linking to individual benchmarked commit in a future-proof way. @@ -26,10 +29,13 @@ which runs benchmarks on a dedicated server with various GPU models. ## Development -- Create JSON data or fetch existing JSON data from the live website. -- Save this JSON data to the `content` folder with the following naming convention: - `YYYY-MM-DD_hash.json` where `hash` is a 9-character Git commit hash of the - Godot build used (truncated from a full commit hash). +- Create JSON data or fetch existing JSON data from the live website, and copy the JSON files into + the `src-data/benchmarks` folder. Files should be named using format `YYYY-MM-DD_hash.json` where + `hash` is a 9-character Git commit hash of the Godot build used (truncated from a full commit hash). + The files can also have the `.md` extension (for backward compatibility), but they should still be + JSON inside. +- Run [./generate-content.py](./generate-content.py). This should create `.md` pages in both the + `content/benchmark` and the `content/graph` folders. - Run `hugo server`. ## Production diff --git a/web/data/.gitkeep b/web/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/web/generate-content.py b/web/generate-content.py index df47723..603257e 100755 --- a/web/generate-content.py +++ b/web/generate-content.py @@ -14,7 +14,7 @@ import json import sys -from os import listdir +import os from os.path import isdir, isfile, join # Source data paths. @@ -40,7 +40,7 @@ data_output_json = { # Fetch the list of benchmark files benchmark_input_filename_test = lambda f: (f.endswith(".json") or f.endswith(".md")) benchmarks_files = [ - f for f in listdir(benchmarks_path) if (isfile(join(benchmarks_path, f)) and benchmark_input_filename_test(f)) + f for f in os.listdir(benchmarks_path) if (isfile(join(benchmarks_path, f)) and benchmark_input_filename_test(f)) ] # Add the list of benchmarks. @@ -48,7 +48,7 @@ for f in benchmarks_files: json_file = open(join(benchmarks_path, f)) # Extract data from filename. - key = f.removesuffix(".json") + key = f.removesuffix(".json").removesuffix(".md") date = key.split("_")[0] commit = key.split("_")[1] @@ -91,12 +91,16 @@ data_file.close() # Create a .md file for each benchmark. benchmarks_content_path = "./content/benchmark" +if not os.path.exists(benchmarks_content_path): + os.mkdir(benchmarks_content_path) for benchmark in data_output_json["benchmarks"]: filename = benchmark["date"] + "_" + benchmark["commit"] + ".md" open(join(benchmarks_content_path, filename), "a").close() # Create a .md file for each graph. graphs_content_path = "./content/graph" +if not os.path.exists(graphs_content_path): + os.mkdir(graphs_content_path) for graph in data_output_json["graphs"]: filename = graph["id"] + ".md" open(join(graphs_content_path, filename), "a").close() diff --git a/web/src-data/benchmarks/.gitkeep b/web/src-data/benchmarks/.gitkeep new file mode 100644 index 0000000..e69de29