diff options
Diffstat (limited to 'internal/flamegraph/worker.go')
| -rw-r--r-- | internal/flamegraph/worker.go | 60 |
1 files changed, 6 insertions, 54 deletions
diff --git a/internal/flamegraph/worker.go b/internal/flamegraph/worker.go index e47329e..a24be6d 100644 --- a/internal/flamegraph/worker.go +++ b/internal/flamegraph/worker.go @@ -2,23 +2,19 @@ package flamegraph import ( "context" + "fmt" "ior/internal/event" - "ior/internal/types" "sync" "time" ) type worker struct { - collapsed collapsed - iod iorData - done chan struct{} + iod iorData + done chan struct{} } func newWorker() worker { - return worker{ - collapsed: make(collapsed), // COLLAPSED: Retire ocne newIorData implemented - iod: newIorData(), // TODO: make flags global, so i don't have to pass them through the whole code base - } + return worker{iod: newIorData()} } func (w worker) run(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pair) { @@ -27,12 +23,8 @@ func (w worker) run(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pa for { select { case ev := <-ch: - // var filePath string - // if ev.File == nil { - // filePath = "N:file" - // } else { - // filePath = ev.File.Name() - // } + fmt.Println("worker got event", ev) + w.iod.add(ev) ev.Recycle() default: @@ -45,43 +37,3 @@ func (w worker) run(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pa } } } - -// TODO: Retire collapsed -func (w worker) runCollapsed(ctx context.Context, wg *sync.WaitGroup, ch <-chan *event.Pair) { - { - defer wg.Done() - - for { - select { - case ev := <-ch: - var filePath string - if ev.File == nil { - filePath = "N:file" - } else { - filePath = ev.File.Name() - } - pathMap, ok := w.collapsed[filePath] - if !ok { - pathMap = make(map[types.TraceId]collapsedCounter) - } - - traceId := ev.EnterEv.GetTraceId() - cnt := pathMap[traceId] - cnt.count++ - cnt.duration += ev.Duration - pathMap[traceId] = cnt - - w.collapsed[filePath] = pathMap - ev.Recycle() - - default: - select { - case <-ctx.Done(): - return - default: - time.Sleep(time.Millisecond * 10) - } - } - } - } -} |
