From d3c7f27c211ebd116803e85d45dca437e635d25e Mon Sep 17 00:00:00 2001 From: thibaud-leclere Date: Tue, 12 May 2026 09:37:12 +0200 Subject: [PATCH] feat: add cachegrind data model --- internal/cachegrind/model.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 internal/cachegrind/model.go diff --git a/internal/cachegrind/model.go b/internal/cachegrind/model.go new file mode 100644 index 0000000..76f8fcf --- /dev/null +++ b/internal/cachegrind/model.go @@ -0,0 +1,26 @@ +package cachegrind + +// Profile holds the parsed contents of a cachegrind file. +type Profile struct { + Cmd string + Events []string + Functions []*Function + ByName map[string][]*Function // one name may appear in multiple files +} + +// Function represents a single profiled function with aggregated inclusive costs. +type Function struct { + Name string + File string + Costs []int64 // one entry per Profile.Events; inclusive (includes callees) + Calls []*Call // outgoing call edges + CalledBy []*Call // incoming call edges +} + +// Call is a directed call edge between two functions. +type Call struct { + Caller *Function + Callee *Function + Count int64 + Costs []int64 +}