def aggregateDetailResults(self, tid, show_all=0):
        """Generate table row cells for the given transaction
        """
        agg = profiler.aggregateDetailResults(tid)

        # do the HTML extra bits
        pm = profileable_modules
        for depth, info in agg.listEvents():
            if info.has_key("events"):
                info["treepart"] = "| " * depth + "+-"
                if info["events"] and info.has_key("ave_time_processing"):
                    min_percent = info["min_percentage_processing"]
                    percent = info["ave_percentage_processing"]
                    max_percent = info["max_percentage_processing"]
                    min_time_display = info["min_time_processing"]
                    time_display = info["ave_time_processing"]
                    max_time_display = info["max_time_processing"]
                else:
                    min_percent = info["min_percentage"]
                    percent = info["ave_percentage"]
                    max_percent = info["max_percentage"]
                    min_time_display = info["min_time_total"]
                    time_display = info["ave_time_total"]
                    max_time_display = info["max_time_total"]
            else:
                info["treepart"] = "| " * depth
                min_percent = info["min_percentage"]
                percent = info["ave_percentage"]
                max_percent = info["max_percentage"]
                min_time_display = info["min_time_total"]
                time_display = info["ave_time_total"]
                max_time_display = info["max_time_total"]

            info["min_time_display"] = min_time_display
            info["time_display"] = time_display
            info["max_time_display"] = max_time_display
            info["min_percentage_display"] = min_percent
            info["percentage_display"] = percent
            info["max_percentage_display"] = max_percent

            info["icon"] = ""
            if info.has_key("meta_type"):
                module = pm[info["meta_type"]]
                if module.icon:
                    info["icon"] = module.icon

            info["percentage_int"] = int(percent / 2)
            if percent > 10:
                info["colour"] = "#ffbbbb"
            elif percent > 5:
                info["colour"] = "#ffdbb9"
            elif percent > 3:
                info["colour"] = "#fff9b9"
            else:
                info["colour"] = ""

        return agg
    def aggregateDetailResults(self, tid, show_all=0):
        '''Generate table row cells for the given transaction
        '''
        agg = profiler.aggregateDetailResults(tid)

        # do the HTML extra bits
        pm = profileable_modules
        for depth, info in agg.listEvents():
            if 'events' in info:
                info['treepart'] = '| ' * depth + '+-'
                if info['events'] and 'ave_time_processing' in info:
                    min_percent = info['min_percentage_processing']
                    percent = info['ave_percentage_processing']
                    max_percent = info['max_percentage_processing']
                    min_time_display = info['min_time_processing']
                    time_display = info['ave_time_processing']
                    max_time_display = info['max_time_processing']
                else:
                    min_percent = info['min_percentage']
                    percent = info['ave_percentage']
                    max_percent = info['max_percentage']
                    min_time_display = info['min_time_total']
                    time_display = info['ave_time_total']
                    max_time_display = info['max_time_total']
            else:
                info['treepart'] = '| ' * depth
                min_percent = info['min_percentage']
                percent = info['ave_percentage']
                max_percent = info['max_percentage']
                min_time_display = info['min_time_total']
                time_display = info['ave_time_total']
                max_time_display = info['max_time_total']

            info['min_time_display'] = min_time_display
            info['time_display'] = time_display
            info['max_time_display'] = max_time_display
            info['min_percentage_display'] = min_percent
            info['percentage_display'] = percent
            info['max_percentage_display'] = max_percent

            info['icon'] = ''
            if 'meta_type' in info:
                module = pm[info['meta_type']]
                if module.icon:
                    info['icon'] = module.icon

            info['percentage_int'] = int(percent / 2)
            if percent > 10:
                info['colour'] = '#ffbbbb'
            elif percent > 5:
                info['colour'] = '#ffdbb9'
            elif percent > 3:
                info['colour'] = '#fff9b9'
            else:
                info['colour'] = ''

        return agg
    def aggregateDetailResults(self, tid, show_all=0):
        '''Generate table row cells for the given transaction
        '''
        agg = profiler.aggregateDetailResults(tid)

        # do the HTML extra bits
        pm = profileable_modules
        for depth, info in agg.listEvents():
            if info.has_key('events'):
                info['treepart'] = '| ' * depth + '+-'
                if info['events'] and info.has_key('ave_time_processing'):
                    min_percent = info['min_percentage_processing']
                    percent = info['ave_percentage_processing']
                    max_percent = info['max_percentage_processing']
                    min_time_display = info['min_time_processing']
                    time_display = info['ave_time_processing']
                    max_time_display = info['max_time_processing']
                else:
                    min_percent = info['min_percentage']
                    percent = info['ave_percentage']
                    max_percent = info['max_percentage']
                    min_time_display = info['min_time_total']
                    time_display = info['ave_time_total']
                    max_time_display = info['max_time_total']
            else:
                info['treepart'] = '| ' * depth
                min_percent = info['min_percentage']
                percent = info['ave_percentage']
                max_percent = info['max_percentage']
                min_time_display = info['min_time_total']
                time_display = info['ave_time_total']
                max_time_display = info['max_time_total']

            info['min_time_display'] = min_time_display
            info['time_display'] = time_display
            info['max_time_display'] = max_time_display
            info['min_percentage_display'] = min_percent
            info['percentage_display'] = percent
            info['max_percentage_display'] = max_percent

            info['icon'] = ''
            if info.has_key('meta_type'):
                module = pm[info['meta_type']]
                if module.icon:
                    info['icon'] = module.icon

            info['percentage_int'] = int(percent / 2)
            if percent > 10: info['colour'] = '#ffbbbb'
            elif percent > 5: info['colour'] = '#ffdbb9'
            elif percent > 3: info['colour'] = '#fff9b9'
            else: info['colour'] = ''

        return agg
    def testAggregate(self):
        self.do_run(0, '1')
        self.do_run2(10, '2')
        self.do_run(20, '3')
        self.do_run2(40, '4')
        self.do_run(60, '5')
        profiler.aggregateResults()

        agg = profiler.aggregateDetailResults('2')
        self.assertEqual(agg.num_runs, 2)
        self.assertEqual(agg.ave_total_time, 10)
        agg = profiler.aggregateDetailResults('4')
        self.assertEqual(agg.events[0]['ave_time_total'], 1)
        self.assertEqual(agg.events[0]['ave_percentage'], 10)
        self.assertEqual(agg.events[1]['ave_time_total'], 7)
        self.assertEqual(agg.events[1]['ave_percentage'], 70)
        self.assertEqual(agg.events[1]['ave_time_processing'], 3)
        self.assertEqual(agg.events[1]['ave_percentage_processing'], 30)

        agg = profiler.aggregateDetailResults('1')
        #print agg.strEvents()
        self.assertEqual(agg.num_runs, 3)
        self.assertEqual(agg.ave_total_time, 10)
    def testAggregate(self):
        self.do_run(0, '1')
        self.do_run2(10, '2')
        self.do_run(20, '3')
        self.do_run2(40, '4')
        self.do_run(60, '5')
        profiler.aggregateResults()

        agg = profiler.aggregateDetailResults('2')
        self.assertEqual(agg.num_runs, 2)
        self.assertEqual(agg.ave_total_time, 10)
        agg = profiler.aggregateDetailResults('4')
        self.assertEqual(agg.events[0]['ave_time_total'], 1)
        self.assertEqual(agg.events[0]['ave_percentage'], 10)
        self.assertEqual(agg.events[1]['ave_time_total'], 7)
        self.assertEqual(agg.events[1]['ave_percentage'], 70)
        self.assertEqual(agg.events[1]['ave_time_processing'], 3)
        self.assertEqual(agg.events[1]['ave_percentage_processing'], 30)

        agg = profiler.aggregateDetailResults('1')
        # print agg.strEvents()
        self.assertEqual(agg.num_runs, 3)
        self.assertEqual(agg.ave_total_time, 10)