diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-06 17:32:24 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-06 17:32:24 +0200 |
| commit | 1561987330cb898f5ff64383a9c78e7e6559f118 (patch) | |
| tree | 69a823e8f98dce572566c97e6879c11c9d591bda /integrationtests/parse_test.go | |
| parent | 96225fb6159212a8851043a08d781aba721b4e78 (diff) | |
| parent | 110a193e04b81abb8d8e159abd73f9f6ed1acd7e (diff) | |
Merge branch 'feat/bubbletea-v2-migration'
Diffstat (limited to 'integrationtests/parse_test.go')
| -rw-r--r-- | integrationtests/parse_test.go | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/integrationtests/parse_test.go b/integrationtests/parse_test.go index 6425298..215b4b8 100644 --- a/integrationtests/parse_test.go +++ b/integrationtests/parse_test.go @@ -3,55 +3,51 @@ package integrationtests import ( "bytes" "encoding/gob" - "ior/internal/file" - "ior/internal/flamegraph" - "ior/internal/types" "os" "path/filepath" "testing" + "ior/internal/file" + "ior/internal/flamegraph" + "ior/internal/types" + "github.com/DataDog/zstd" ) // writeIorZst creates a minimal .ior.zst file from known data. -// It encodes a pathMap (the same nested-map structure used internally by iorData) -// so that LoadTestResult can decode it via the public flamegraph.LoadFromFile API. +// It encodes the current record-key map format used by flamegraph iorData. func writeIorZst(t *testing.T, dir string, records []flamegraph.IterRecord) string { t.Helper() - // Build the nested map matching iorData.paths layout: - // path → traceId → comm → pid → tid → flags → Counter - type ( - flagsMap = map[file.Flags]flamegraph.Counter - tidMap = map[uint32]flagsMap - pidMap = map[uint32]tidMap - commMap = map[string]pidMap - traceIdMap = map[types.TraceId]commMap - pathMapType = map[string]traceIdMap - ) - - paths := make(pathMapType) + type recordKey struct { + Path string + TraceID types.TraceId + Comm string + Pid uint32 + Tid uint32 + Flags file.Flags + } + + flat := make(map[recordKey]flamegraph.Counter) for _, r := range records { - if paths[r.Path] == nil { - paths[r.Path] = make(traceIdMap) - } - if paths[r.Path][r.TraceID] == nil { - paths[r.Path][r.TraceID] = make(commMap) - } - if paths[r.Path][r.TraceID][r.Comm] == nil { - paths[r.Path][r.TraceID][r.Comm] = make(pidMap) - } - if paths[r.Path][r.TraceID][r.Comm][r.Pid] == nil { - paths[r.Path][r.TraceID][r.Comm][r.Pid] = make(tidMap) - } - if paths[r.Path][r.TraceID][r.Comm][r.Pid][r.Tid] == nil { - paths[r.Path][r.TraceID][r.Comm][r.Pid][r.Tid] = make(flagsMap) + key := recordKey{ + Path: r.Path, + TraceID: r.TraceID, + Comm: r.Comm, + Pid: r.Pid, + Tid: r.Tid, + Flags: r.Flags, } - paths[r.Path][r.TraceID][r.Comm][r.Pid][r.Tid][r.Flags] = r.Cnt + current := flat[key] + current.Count += r.Cnt.Count + current.Duration += r.Cnt.Duration + current.DurationToPrev += r.Cnt.DurationToPrev + current.Bytes += r.Cnt.Bytes + flat[key] = current } var buf bytes.Buffer - if err := gob.NewEncoder(&buf).Encode(paths); err != nil { + if err := gob.NewEncoder(&buf).Encode(flat); err != nil { t.Fatalf("gob encode: %v", err) } |
