init eACGM
This commit is contained in:
1
eacgm/collector/__init__.py
Normal file
1
eacgm/collector/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .profetto import to_perfetto
|
21
eacgm/collector/profetto.py
Normal file
21
eacgm/collector/profetto.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import List
|
||||
|
||||
from eacgm.sampler import eBPFSamplerState
|
||||
|
||||
def to_perfetto(states:List[eBPFSamplerState]) -> List:
|
||||
res = []
|
||||
last_event = {}
|
||||
for state in states:
|
||||
if not isinstance(state, eBPFSamplerState):
|
||||
continue
|
||||
state = state.collect()
|
||||
name = f"{state['name']}-{state['pid']}"
|
||||
last_state = last_event.get(name, None)
|
||||
if last_state is None:
|
||||
last_event[name] = state
|
||||
continue
|
||||
if last_state["ph"] == "B" and state["ph"] == "E":
|
||||
res.append(last_state)
|
||||
res.append(state)
|
||||
last_event[name] = state
|
||||
return res
|
Reference in New Issue
Block a user