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 +}