summaryrefslogtreecommitdiff
path: root/internal/flamegraph/flamegraph.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-10 21:28:45 +0300
committerPaul Buetow <paul@buetow.org>2025-04-10 21:28:45 +0300
commit017494938f061fd1276f2a54b1df0e7002655e9f (patch)
tree9c98fbf31b524233b637079a0482b4255eb6e388 /internal/flamegraph/flamegraph.go
parent9572fa5d087731f68d55517847833f6203b9a70d (diff)
can serialize and deserialize to/from gob
Diffstat (limited to 'internal/flamegraph/flamegraph.go')
-rw-r--r--internal/flamegraph/flamegraph.go60
1 files changed, 0 insertions, 60 deletions
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)
- }
- }()
-}