From feb2fef707bbdaadae3247e7035b17b3efa69c9c Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Mon, 2 Feb 2026 23:11:44 +0100 Subject: [PATCH 1/2] Ignore elm-pages internal files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a0ccf0cb..5668680f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ node_modules .direnv dist generated +.elm-pages From b7762b25ef15696391033e64a58c1f260aca2d74 Mon Sep 17 00:00:00 2001 From: Leonardo Taglialegne Date: Tue, 3 Feb 2026 00:06:29 +0100 Subject: [PATCH 2/2] Add flag for faster profiling --- .gitignore | 1 + cli/custom-backend-task.js | 7 ++++ cli/src/TestGenScript.elm | 74 +++++++++++++++++++++++++++++--------- 3 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 cli/custom-backend-task.js diff --git a/.gitignore b/.gitignore index 5668680f..bd9150c6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ node_modules dist generated .elm-pages +*.cpuprofile diff --git a/cli/custom-backend-task.js b/cli/custom-backend-task.js new file mode 100644 index 00000000..41e4eb0a --- /dev/null +++ b/cli/custom-backend-task.js @@ -0,0 +1,7 @@ +export function profile(label) { + console.profile(label); +} + +export function profileEnd(label) { + console.profileEnd(label); +} diff --git a/cli/src/TestGenScript.elm b/cli/src/TestGenScript.elm index 99e647c2..c8d63a38 100644 --- a/cli/src/TestGenScript.elm +++ b/cli/src/TestGenScript.elm @@ -1,8 +1,15 @@ module TestGenScript exposing (run) import Ansi.Color -import BackendTask +import BackendTask exposing (BackendTask) +import BackendTask.Custom import Cli +import Cli.Option +import Cli.OptionsParser +import Cli.Program +import FatalError exposing (FatalError) +import Json.Decode +import Json.Encode import OpenApi.Config import Pages.Script @@ -99,37 +106,72 @@ run = telegramBot = OpenApi.Config.inputFrom (OpenApi.Config.File "./example/telegram-bot.json") - config : OpenApi.Config.Config - config = + profileConfig : OpenApi.Config.Config + profileConfig = + -- Slimmed config for profiling OpenApi.Config.init "./generated" - |> OpenApi.Config.withAutoConvertSwagger OpenApi.Config.AlwaysConvert |> OpenApi.Config.withInput additionalProperties |> OpenApi.Config.withInput recursiveAllofRefs |> OpenApi.Config.withInput overridingGlobalSecurity |> OpenApi.Config.withInput singleEnum - |> OpenApi.Config.withInput patreon |> OpenApi.Config.withInput realworldConduit |> OpenApi.Config.withInput amadeusAirlineLookup - |> OpenApi.Config.withInput dbFahrplanApi |> OpenApi.Config.withInput marioPartyStats |> OpenApi.Config.withInput viaggiatreno |> OpenApi.Config.withInput trustmark |> OpenApi.Config.withInput trustmarkTradeCheck - |> OpenApi.Config.withInput gitHub |> OpenApi.Config.withInput ifconfigOvh |> OpenApi.Config.withInput anyOfEnums |> OpenApi.Config.withInput binaryResponse |> OpenApi.Config.withInput nullableEnum |> OpenApi.Config.withInput cookieAuth + + config : OpenApi.Config.Config + config = + profileConfig + |> OpenApi.Config.withInput patreon + |> OpenApi.Config.withInput dbFahrplanApi + |> OpenApi.Config.withInput gitHub |> OpenApi.Config.withInput telegramBot + |> OpenApi.Config.withAutoConvertSwagger OpenApi.Config.AlwaysConvert in - Pages.Script.withoutCliOptions - (BackendTask.doEach - [ Cli.withConfig config - , "\nCompiling Example app" - |> Ansi.Color.fontColor Ansi.Color.brightGreen - |> Pages.Script.log - , Pages.Script.exec "sh" - [ "-c", "cd example && npx --no -- elm make src/Example.elm --output=/dev/null" ] - ] + Pages.Script.withCliOptions programConfig + (\profile -> + if profile then + profiling "main" (Cli.withConfig profileConfig) + + else + BackendTask.doEach + [ Cli.withConfig config + , "\nCompiling Example app" + |> Ansi.Color.fontColor Ansi.Color.brightGreen + |> Pages.Script.log + , Pages.Script.exec "sh" + [ "-c", "cd example && npx --no -- elm make src/Example.elm --output=/dev/null" ] + ] ) + + +programConfig : Cli.Program.Config Bool +programConfig = + Cli.Program.config + |> Cli.Program.add + (Cli.OptionsParser.build identity + |> Cli.OptionsParser.with (Cli.Option.flag "profile") + ) + + +profiling : String -> BackendTask FatalError a -> BackendTask FatalError a +profiling label task = + BackendTask.Custom.run "profile" (Json.Encode.string label) (Json.Decode.succeed ()) + |> BackendTask.allowFatal + |> BackendTask.andThen + (\() -> + task + ) + |> BackendTask.andThen + (\res -> + BackendTask.Custom.run "profileEnd" (Json.Encode.string label) (Json.Decode.succeed ()) + |> BackendTask.allowFatal + |> BackendTask.map (\() -> res) + )