This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Writing importer
Alex edited this page Aug 11, 2017
·
1 revision
IntelSEAPI provides simple interface for reporting various profiling entities. Lots of working examples you can find in https://github.com/01org/IntelSEAPI/tree/master/runtool/importers
Importer is a python file that is found in runtool/importers folder and has registration record.
class Parser:
def __init__(self, args, callbacks):
self.args = args
self.callbacks = callbacks
def on_line(self, line, num):
# do your parsing here
def finish(self):
# sometimes you need to do something at the end
def transform(args):
tree = default_tree(args)
tree['ring_buffer'] = True
args.no_left_overs = True
with Callbacks(args, tree) as callbacks:
if callbacks.is_empty():
return callbacks.get_result()
parser = Parser(args, callbacks)
count = 0
with Progress(os.path.getsize(args.input), 50, "Parsing: " + os.path.basename(args.input)) as progress:
with open(args.input) as file:
for line in file:
parser.on_line(line.strip(), count)
count += 1
if not count % 1000:
progress.tick(file.tell())
parser.finish()
return callbacks.get_result()
IMPORTER_DESCRIPTORS = [{
'format': 'your format extension',
'available': True, #leave it as True if your parser doesn't depend on anything or check dependency and return False when it is not satisfied
'importer': transform
}]
In the Parser class call methods exposed from self.callbacks:
To report a stack:
self.callbacks.handle_stack(pid, tid, time, stack)
To report VSync:
self.callbacks.vsync(time)
To give process a name:
self.callbacks.set_process_name(pid, name)
To give thread a name:
self.callbacks.set_thread_name(pid, tid, name)
To report a context switch:
self.callbacks.context_switch(time, cpu, prev_tid, next_tid)
To add a global meta-data:
self.callbacks.add_metadata(name, data_dict)
Rest of the events are process/thread related, so you need to create the thread instance inside process:
thread = self.callbacks.process(pid).thread(tid)
Then:
To report a task:
thread.task(name).complete(time, duration)
To report a counter:
thread.counter(name).set_value(time, value)
With respect, Alexander Raud.