The codebase implementation is a complex thing with a lot of moving pieces, and we often find ourselves wanting to get diagnostic information about how it's doing its thing. A recent example: we added some caching for terms/type signatures/decls and wanted to see the cache hit rate and how much time it saves.
Another example: how much time is being spent by various operations in the codebase? Ideally, we could add these diagnostics without it turning into a big refactoring each time, and without hacks like using Debug.Trace that spam the console.
My idea is to add a new function on Codebase, called metrics:
metrics :: m Metrics
Where Metrics is a thing with an interface like:
Metrics.new :: IO Metrics
-- returns a function to increment the counter
Metrics.counter :: Metrics -> Text -> IO (Int -> IO ())
-- returns a functions for get and modify
Metrics.gauge :: Metrics -> Text -> a -> IO (IO a, (a -> a) -> IO a)
Metrics.display :: Metrics -> IO String
Metrics.displayOnly :: Text -> IO String
We could add ucm commands for getting at these metrics.
The codebase implementation is a complex thing with a lot of moving pieces, and we often find ourselves wanting to get diagnostic information about how it's doing its thing. A recent example: we added some caching for terms/type signatures/decls and wanted to see the cache hit rate and how much time it saves.
Another example: how much time is being spent by various operations in the codebase? Ideally, we could add these diagnostics without it turning into a big refactoring each time, and without hacks like using Debug.Trace that spam the console.
My idea is to add a new function on
Codebase
, calledmetrics
:Where
Metrics
is a thing with an interface like:We could add ucm commands for getting at these metrics.
—
Created via Raycast