-module(temporal_diff_benchmark). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/temporal_diff_benchmark.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. -file("src/temporal_diff_benchmark.gleam", 98). -spec percentile_index(integer(), integer()) -> integer(). percentile_index(Count, Percentile) -> Percentage = (Count * Percentile) div 100, gleam@int:max(0, Percentage - 1). -file("src/temporal_diff_benchmark.gleam", 85). -spec print_latency(binary(), list(integer())) -> nil. print_latency(Label, Samples) -> Sorted = gleam@list:sort(Samples, fun gleam@int:compare/2), Count = erlang:length(Sorted), Total = gleam@list:fold(Samples, 0, fun(Sum, Value) -> Sum + Value end), P50@1 = case begin _pipe = gleam@list:drop(Sorted, percentile_index(Count, 50)), gleam@list:first(_pipe) end of {ok, P50} -> P50; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"temporal_diff_benchmark"/utf8>>, function => <<"print_latency"/utf8>>, line => 89, value => _assert_fail, start => 2602, 'end' => 2689, pattern_start => 2613, pattern_end => 2620}) end, P95@1 = case begin _pipe@1 = gleam@list:drop(Sorted, percentile_index(Count, 95)), gleam@list:first(_pipe@1) end of {ok, P95} -> P95; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"temporal_diff_benchmark"/utf8>>, function => <<"print_latency"/utf8>>, line => 91, value => _assert_fail@1, start => 2692, 'end' => 2779, pattern_start => 2703, pattern_end => 2710}) end, gleam_stdlib:println( <<<