From 017494938f061fd1276f2a54b1df0e7002655e9f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 10 Apr 2025 21:28:45 +0300 Subject: can serialize and deserialize to/from gob --- internal/flamegraph/flamegraph.go | 60 --------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 internal/flamegraph/flamegraph.go (limited to 'internal/flamegraph/flamegraph.go') diff --git a/internal/flamegraph/flamegraph.go b/internal/flamegraph/flamegraph.go deleted file mode 100644 index 9772f0c..0000000 --- a/internal/flamegraph/flamegraph.go +++ /dev/null @@ -1,60 +0,0 @@ -package flamegraph - -import ( - "context" - "fmt" - "ior/internal/event" - "ior/internal/flags" - "log" - "runtime" - "sync" -) - -// TODO: Add Command in path! Make it configurable? comm/syscall/path, or path/syscall/comm, etc... -// TODO: Idea, show time spent between the syscalls (off syscalls) as well, but in a different color -type Flamegraph struct { - flags flags.Flags - Ch chan *event.Pair - Done chan struct{} - workers []worker -} - -func New() Flamegraph { - f := Flamegraph{ - Ch: make(chan *event.Pair, 4096), - Done: make(chan struct{}), - } - numWorkers := runtime.NumCPU() / 4 - if numWorkers == 0 { - numWorkers = 1 - } - for range numWorkers { - f.workers = append(f.workers, newWorker()) - } - return f -} - -func (f Flamegraph) Start(ctx context.Context) { - go func() { - defer close(f.Done) - var wg sync.WaitGroup - wg.Add(len(f.workers)) - - for i, worker := range f.workers { - fmt.Println("Starting flamegraph worker", i) - go worker.run(ctx, &wg, f.Ch) - } - wg.Wait() - - iod := f.workers[0].iod - if len(f.workers) > 1 { - for i, w := range f.workers[1:] { - iod = iod.merge(w.iod) - fmt.Println("Worker", i+1, "merged") - } - } - if err := iod.commit(); err != nil { - log.Fatal(err) - } - }() -} -- cgit v1.2.3