[go: up one dir, main page]

File: t208_watch_cpu.py

package info (click to toggle)
uftrace 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,212 kB
  • sloc: ansic: 53,313; python: 9,846; makefile: 838; asm: 703; cpp: 602; sh: 560; javascript: 191
file content (38 lines) | stat: -rw-r--r-- 1,221 bytes parent folder | download
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
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python

import re

from runtest import TestBase

class TestCase(TestBase):
    def __init__(self):
        TestBase.__init__(self, 'chcpu', serial=True, result="""
# DURATION     TID     FUNCTION
            [320248] | main() {
            [320248] |   /* watch:cpu (cpu=1) */
  23.252 us [320248] |   sysconf();
   0.667 us [320248] |   sched_getcpu();
            [320248] |   sched_setaffinity() {
            [320248] |     /* watch:cpu (cpu=0) */
  75.337 us [320248] |   } /* sched_setaffinity */
            [320248] |   sched_setaffinity() {
            [320248] |     /* watch:cpu (cpu=1) */
  40.668 us [320248] |   } /* sched_setaffinity */
 146.590 us [320248] | } /* main */
""")

    def setup(self):
        # ignore unexpected memset on ARM (raspbian)
        self.option = '-F main -W cpu -N memset --no-sched'

    def sort(self, output):
        result = []
        for ln in output.split('\n'):
            # ignore blank lines and comments
            if ln.strip() == '' or ln.startswith('#'):
                continue
            line = ln.split('|', 1)[-1]
            func = re.sub(r'cpu=[0-9a-f]+', 'cpu=N', line)
            result.append(func)

        return '\n'.join(result)