File: otf2_reader.py

package info (click to toggle)
otf2 3.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,000 kB
  • sloc: ansic: 92,997; python: 16,977; cpp: 9,057; sh: 6,299; makefile: 238; awk: 54
file content (25 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python

import otf2
from otf2.events import *
import time
from tempfile import mkdtemp
import os
import otf2_writer


def read_trace(archive_name="TestArchive/traces.otf2"):
    with otf2.reader.open(archive_name) as trace:
        print("Read {} definitions".format(len(trace.definitions.strings)))

        for location, event in trace.events:
            print("Encountered event on location {} at {}".format(location, event))


if __name__ == '__main__':
    trace_dir = mkdtemp(prefix="trace_test.", dir=os.getcwd())
    os.rmdir(trace_dir)
    otf2_writer.generate_trace(trace_dir)
    print("Created trace in {}".format(trace_dir))
    read_trace("{}/traces.otf2".format(trace_dir))
    print("Read trace from {}/traces.otf2".format(trace_dir))