-module(internal@bench@simple_pathfinding). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/internal/bench/simple_pathfinding.gleam"). -export([main/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Simple Pathfinding Benchmark\n" "\n" " Compares Dijkstra's algorithm across different graph sizes\n" " Run with: gleam run -m internal/bench/simple_pathfinding\n" ). -file("src/internal/bench/simple_pathfinding.gleam", 46). -spec bench_dijkstra({yog@model:graph(nil, integer()), integer(), integer()}) -> nil. bench_dijkstra(Input) -> {Graph, From, To} = Input, _ = yog@pathfinding:shortest_path( Graph, From, To, 0, fun gleam@int:add/2, fun gleam@int:compare/2 ), nil. -file("src/internal/bench/simple_pathfinding.gleam", 13). -spec main() -> nil. main() -> gleam_stdlib:println( <<"\n╔════════════════════════════════════════════════════════════╗"/utf8>> ), gleam_stdlib:println( <<"║ PATHFINDING BENCHMARK - GRAPH SIZE SCALING ║"/utf8>> ), gleam_stdlib:println( <<"╚════════════════════════════════════════════════════════════╝\n"/utf8>> ), gleam_stdlib:println( <<"Benchmarking: How does Dijkstra scale with graph size?"/utf8>> ), gleam_stdlib:println(<<"Expected: O((V+E) log V) complexity\n"/utf8>>), Small = internal@bench@bench_utils:random_graph(small, sparse, 42), Medium = internal@bench@bench_utils:random_graph(medium, sparse, 42), Inputs = [{input, <<"Small: 100 nodes"/utf8>>, {Small, 0, 99}}, {input, <<"Medium: 1K nodes"/utf8>>, {Medium, 0, 999}}], Functions = [{function, <<"Dijkstra"/utf8>>, fun bench_dijkstra/1}], _pipe = gleamy@bench:run( Inputs, Functions, [{duration, 2000}, {warmup, 500}] ), _pipe@1 = gleamy@bench:table(_pipe, [i_p_s, min, max, {p, 99}]), gleam_stdlib:println(_pipe@1), gleam_stdlib:println( <<"\n╔════════════════════════════════════════════════════════════╗"/utf8>> ), gleam_stdlib:println( <<"║ BENCHMARK COMPLETE ║"/utf8>> ), gleam_stdlib:println( <<"╚════════════════════════════════════════════════════════════╝\n"/utf8>> ).