Ejemplo n.º 1
0
    def complete_task(self, type, begin, end):
        if 'tid' not in begin:
            return

        start_time = round(begin['time'] /
                           1000)  # sad but it's limiter to milliseconds only
        end_time = round(end['time'] / 1000)
        dur = end_time - start_time
        if dur < self.args.min_dur:
            return

        name = get_name(begin)

        details = (type + ":") if type != 'task' else ""
        if begin.has_key('parent'):
            details += to_hex(begin['parent']) + "->"
        details += name

        if type == 'counter' or type == 'marker':
            kind = 'Painting'
        elif type == 'frame' or 'object_' in type:
            kind = 'Creating'
        else:
            kind = 'Javascript'

        record = (begin['__file__'].replace("\\", "/")
                  if begin.has_key('__file__') else "",
                  begin['__line__'] if begin.has_key('__line__') else "0",
                  kind, "%s | %s" % (details, begin['domain']), name)
        record = tuple([cgi.escape(item) for item in record])

        if self.event_map.has_key(record):
            index = self.event_map[record]
        else:
            index = len(self.events)
            self.events.append(record)
            self.event_map[record] = index

        tag = '<range startTime="%d" duration="%d" eventIndex="%d"/>\n' % (
            start_time, dur, index)

        args = {}
        if type == "counter":
            if 'delta' in begin:
                args['value'] = begin['delta']
            else:  # TODO: add multi-value support
                return
        if begin.has_key('args'):
            args = begin['args']
            if end.has_key('args'):
                args.update(end['args'])
        if args:
            self.notes.append((start_time, dur, index, args))

        self.set_times(start_time, end_time)
        self.file.write(tag)
Ejemplo n.º 2
0
    def complete_task(self, type, begin, end):
        if 'tid' not in begin:
            return

        start_time = round(begin['time'] / 1000)  # sad but it's limiter to milliseconds only
        end_time = round(end['time'] / 1000)
        dur = end_time - start_time
        if dur < self.args.min_dur:
            return

        name = get_name(begin)

        details = (type + ":") if type != 'task' else ""
        if begin.has_key('parent'):
            details += to_hex(begin['parent']) + "->"
        details += name

        if type == 'counter' or type == 'marker':
            kind = 'Painting'
        elif type == 'frame' or 'object_' in type:
            kind = 'Creating'
        else:
            kind = 'Javascript'

        record = (
            begin['__file__'].replace("\\", "/") if begin.has_key('__file__') else "",
            begin['__line__'] if begin.has_key('__line__') else "0",
            kind,
            "%s | %s" % (details, begin['domain']),
            name
        )
        record = tuple([cgi.escape(item) for item in record])

        if self.event_map.has_key(record):
            index = self.event_map[record]
        else:
            index = len(self.events)
            self.events.append(record)
            self.event_map[record] = index

        tag = '<range startTime="%d" duration="%d" eventIndex="%d"/>\n' % (start_time, dur, index)

        args = {}
        if type == "counter":
            args['value'] = begin['delta']
        if begin.has_key('args'):
            args = begin['args']
            if end.has_key('args'):
                args.update(end['args'])
        if args:
            self.notes.append((start_time, dur, index, args))

        self.set_times(start_time, end_time)
        self.file.write(tag)