(self)
| 1907 | entry.samples += callee.samples |
| 1908 | |
| 1909 | def parse(self): |
| 1910 | self.readline() |
| 1911 | self.readline() |
| 1912 | self.readline() |
| 1913 | self.readline() |
| 1914 | |
| 1915 | match = re.compile(r'(?P<prefix>[|+ ]*)(?P<samples>\d+), (?P<symbol>[^,]+), (?P<image>.*)') |
| 1916 | |
| 1917 | while self.lookahead(): |
| 1918 | line = self.consume() |
| 1919 | mo = match.match(line) |
| 1920 | if not mo: |
| 1921 | raise ParseError('failed to parse', line) |
| 1922 | |
| 1923 | fields = mo.groupdict() |
| 1924 | prefix = len(fields.get('prefix', 0)) / 2 - 1 |
| 1925 | |
| 1926 | symbol = str(fields.get('symbol', 0)) |
| 1927 | image = str(fields.get('image', 0)) |
| 1928 | |
| 1929 | entry = Struct() |
| 1930 | entry.id = ':'.join([symbol, image]) |
| 1931 | entry.samples = int(fields.get('samples', 0)) |
| 1932 | |
| 1933 | entry.name = symbol |
| 1934 | entry.image = image |
| 1935 | |
| 1936 | # adjust the callstack |
| 1937 | if prefix < len(self.stack): |
| 1938 | del self.stack[prefix:] |
| 1939 | |
| 1940 | if prefix == len(self.stack): |
| 1941 | self.stack.append(entry) |
| 1942 | |
| 1943 | # if the callstack has had an entry, it's this functions caller |
| 1944 | if prefix > 0: |
| 1945 | self.add_callee(self.stack[prefix - 1], entry) |
| 1946 | |
| 1947 | self.add_entry(entry) |
| 1948 | |
| 1949 | profile = Profile() |
| 1950 | profile[SAMPLES] = 0 |
| 1951 | for _function, _callees in self.entries.values(): |
| 1952 | function = Function(_function.id, _function.name) |
| 1953 | function[SAMPLES] = _function.samples |
| 1954 | profile.add_function(function) |
| 1955 | profile[SAMPLES] += _function.samples |
| 1956 | |
| 1957 | if _function.image: |
| 1958 | function.module = os.path.basename(_function.image) |
| 1959 | |
| 1960 | for _callee in _callees.values(): |
| 1961 | call = Call(_callee.id) |
| 1962 | call[SAMPLES] = _callee.samples |
| 1963 | function.add_call(call) |
| 1964 | |
| 1965 | # compute derived data |
| 1966 | profile.validate() |
nothing calls this directly
no test coverage detected