From 682b3a2ce53252b2bd0c0da86c89c392f74f68e0 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 18 May 2026 22:18:09 +0900 Subject: [PATCH] internal/rosa: track evaluation time Useful to track performance regressions over migrations. Signed-off-by: Ophestra --- cmd/mbf/main.go | 9 +++++++++ internal/rosa/rosa.go | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go index 69e84fce..526dce50 100644 --- a/cmd/mbf/main.go +++ b/cmd/mbf/main.go @@ -84,12 +84,17 @@ func main() { flagArch string flagCheck bool flagLTO bool + flagET bool flagCrossOverride int addr net.UnixAddr ) c := command.New(os.Stderr, log.Printf, "mbf", func([]string) error { + if flagET { + log.Println("evaluated in", rosa.EvalTime()) + } + msg.SwapVerbose(!flagQuiet) cm.ctx, cm.msg = ctx, msg cm.base = os.ExpandEnv(cm.base) @@ -183,6 +188,10 @@ func main() { &addr.Name, "socket", command.StringFlag("$MBF_DAEMON_SOCKET"), "Pathname of socket to bind to", + ).Flag( + &flagET, + "eval-time", command.BoolFlag(false), + "Print duration of the initial azalea evaluation", ) c.NewCommand( diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index d9d0b9ef..b29fd605 100644 --- a/internal/rosa/rosa.go +++ b/internal/rosa/rosa.go @@ -10,6 +10,7 @@ import ( "strconv" "strings" "sync" + "time" "hakurei.app/fhs" "hakurei.app/internal/pkg" @@ -612,6 +613,12 @@ var native S // Native returns the global [S]. func Native() *S { return &native } +// evalTime is the duration of the initial built-in evaluation. +var evalTime time.Duration + +// EvalTime returns the duration of the initial built-in evaluation. +func EvalTime() time.Duration { return evalTime } + // nativeB is the backing directory of built-in azalea-based [Artifact] // implementations. // @@ -623,8 +630,10 @@ func init() { if err != nil { panic(err) } + t := time.Now() if err = native.EvaluateFS(sub); err != nil { println(err.Error()) os.Exit(1) } + evalTime = time.Since(t) }