diff --git a/test/bench.sh b/test/bench.sh index 9585625..c926892 100755 --- a/test/bench.sh +++ b/test/bench.sh @@ -9,3 +9,9 @@ go build ./test.go hyperfine "./test ./1MB.json" "./test -libjson=false ./1MB.json" hyperfine "./test ./5MB.json" "./test -libjson=false ./5MB.json" hyperfine "./test ./10MB.json" "./test -libjson=false ./10MB.json" + +hyperfine "./test ./1K_recursion.json" "./test -libjson=false ./10MB.json" +hyperfine "./test ./10_recursion.json" "./test -libjson=false ./10MB.json" +hyperfine "./test ./100K_recursion.json" "./test -libjson=false ./10MB.json" +hyperfine "./test ./1M_recursion.json" "./test -libjson=false ./10MB.json" +hyperfine "./test ./10M_recursion.json" "./test -libjson=false ./10MB.json" diff --git a/test/gen.py b/test/gen.py index 50d2bcb..e6b6c95 100644 --- a/test/gen.py +++ b/test/gen.py @@ -1,3 +1,4 @@ +import os from os.path import exists import math @@ -20,3 +21,34 @@ def write_data(size: int): f.write("\n]") [write_data(size) for size in sizes] + +depths = { + "1K": 1_000, + "10K": 10_000, + "100K": 100_000, + "1M": 1_000_000, + "10M": 10_000_000, +} + +for depth_name, depth in depths.items(): + print(f"Generating {depth} depth object") + + json_parts = ["{"] + + for _ in range(1, depth): + json_parts.append('"next":{') + + json_parts.append('"next":null') + + for _ in range(depth): + json_parts.append("}") + + json_string = "".join(json_parts) + + file_name = f"{depth_name}_recursion.json" + file_path = os.path.join(os.path.dirname(__file__), file_name) + + with open(file_path, 'w') as f: + f.write(json_string) + + print(f"File for depth {depth} saved as {file_name}")