Example #1
0
    def create_diff_chart(self, key, report_dir):
        """
        Generate the diff chart for the specified key, comparing the
        two reports for this diff.

        `key`:
            A section key that appears in both reports

        `report_dir`:
            The directory to write the data, gnuplot, and image files
        """
        output_name = 'diff_{hash}'.format(hash=hashlib.md5(str(key)).hexdigest())
        per_second_name = output_name + '.per_second.png'
        response_times_name = output_name + '.response.png'
        per_second_path = gnuplot_scriptpath(report_dir, per_second_name)
        response_times_path = gnuplot_scriptpath(report_dir, response_times_name)
        gplot_path = str(os.path.join(report_dir, output_name + '.gplot'))
        data_path = gnuplot_scriptpath(report_dir, output_name + '.data')

        labels = []
        data = []

        left_data = self.data1[key]
        right_data = self.data2[key]

        columns = set(left_data.keys()) & set(right_data.keys())
        cycles = [int(v) for v in left_data['CUs']]

        for column_name in columns:
            labels.extend(['L_' + column_name, 'R_' + column_name])

        for idx in range(len(cycles)):
            values = []
            for column_name in columns:
                values.append(left_data[column_name][idx])
                values.append(right_data[column_name][idx])
            data.append(values)

        with open(data_path, 'w') as data_file:
            data_file.write(render_template(
                'gnuplot/data.mako',
                labels=labels,
                data=data
            ))

        with open(gplot_path, 'w') as gplot_file:
            gplot_file.write(render_template(
                'gnuplot/diff.mako',
                per_second_path=per_second_path,
                response_times_path=response_times_path,
                use_xticlabels=not strictly_monotonic(cycles),
                left_path=self.report1,
                right_path=self.report2,
                data_path=data_path,
                key=key,
                column_names=labels,
            ))
        gnuplot(gplot_path)

        return (per_second_name, response_times_name)
Example #2
0
    def render(self, output_format, image_paths={}):
        """
        Create the report in the specified output format

        `output_format`:
            The output format of the report (currently, can be rst or org)

        `image_paths`: dict
            A dictionary mapping image keys to their paths on disk
        """
        reports = self.args
        reports_date = [extract_date(report) for report in reports]
        self.max_cus = extract_max_cus(reports[0])
        return render_template(
            '{output_format}/trend.mako'.format(output_format=output_format),
            reports=zip(self.reports_name, reports_date, self.reports_metadata),
            comparable_keys=self.comparable_keys,
            image_paths=image_paths,
        )
Example #3
0
    def render(self, output_format, image_paths={}):
        """
        Create the report in the specified output format

        `output_format`:
            The output format of the report (currently, can be rst or org)

        `image_paths`: dict
            A dictionary mapping image keys to their paths on disk
        """
        return render_template(
            '{output_format}/diff.mako'.format(output_format=output_format),
            left_path=self.report1,
            left_name=os.path.basename(os.path.dirname(self.report1)),
            right_path=self.report2,
            right_name=os.path.basename(os.path.dirname(self.report2)),
            comparable_keys=self.comparable_keys,
            left_keys=set(self.data1.keys()),
            right_keys=set(self.data2.keys()),
            image_paths=image_paths,
        )
Example #4
0
 def render(self, output_format, image_paths={}):
     """
     Return the content of this bench report
     
     `output_format`: string
         The output format to render this report in
     
     `image_paths`: dict
         A dictionary mapping image keys to their paths on disk
     """
     return render_template(
         '{output_format}/bench.mako'.format(output_format=output_format),
         cycles = self.cycles,
         stats_columns=STATS_COLUMNS,
         allstats=self.stats,
         aggregate_stats=self.aggr_stats,
         image_paths=image_paths,
         config=self.config,
         date=self.date,
         apdex_t="%.1f" % self.options.apdex_t,
         monitor_hosts=self.monitor,
     )
Example #5
0
    def createResultChart(self, key, stats, report_dir):
        """
        Create a single result chart using a specified key and report directory

        `key`:
            The key used to identify this result. Is hashed to generate a filename

        `stats`:
            A map of cycle to StatsAccumulator or StatsAggregator to generate the chart from

        `report_dir`:
            The directory to write the data, gnuplot, and image files
        
        Returns the relative path of the generated image in the report_dir
        """
        output_name = 'results_{hash}'.format(hash=hashlib.md5(str(key)).hexdigest())
        image_name = output_name + '.png'
        image_path = gnuplot_scriptpath(report_dir, image_name)
        gplot_path = str(os.path.join(report_dir, output_name + '.gplot'))
        data_path = gnuplot_scriptpath(report_dir, output_name + '.data')

        # data
        labels = STATS_COLUMNS + ["E", "G", "F", "P", "U"]
        data = []
        has_error = False
        apdex_t = self.options.apdex_t
        for cycle, cycle_stats in stats.items():
            values = [self.cycles[cycle]] + cycle_stats.stats_list()
            if cycle_stats.errors > 0:
                has_error = True
            score = cycle_stats.apdex_score

            apdex = ['0', '0', '0', '0', '0']
            if score < 0.5:
                apdex[4] = str(score)
            elif score < 0.7:
                apdex[3] = str(score)
            elif score < 0.85:
                apdex[2] = str(score)
            elif score < 0.94:
                apdex[1] = str(score)
            else:
                apdex[0] = str(score)
            data.append(values + apdex)
        if len(data) == 0:
            # No pages finished during a cycle
            return

        with open(data_path, 'w') as data_file:
            data_file.write(render_template('gnuplot/data.mako',
                labels=labels,
                data=data
            ))
        
        with open(gplot_path, 'w') as gplot_file:
            gplot_file.write(render_template('gnuplot/result.mako',
                image_path=image_path,
                chart_size=[800, 800],
                maxCVUs=max(self.cycles),
                datapoints=len(self.cycles),
                use_xticlabels=not strictly_monotonic(self.cycles),
                data_path=data_path,
                has_error=has_error,
                apdex_t="%0.1f" % apdex_t,
                column_names=labels,
                shared={}
            ))
        gnuplot(gplot_path)

        return image_name
Example #6
0
    def create_trend_chart(self, key, report_dir):
        """
        Create a chart showing data trends for the specified key across all stored reports.

        Returns a tuple with of 3 image paths, relative to the report dir:
        (entries per second, average response time, apdex score)

        `key`:
            A section key that exists in self.reports_data, that specifies the data to trend
            over

        `report_dir`:
            The path to the output directory to write the data, gnuplot, and images to
        """
        output_name = 'trend_{hash}'.format(hash=hashlib.md5(str(key)).hexdigest())
        per_second_name = output_name + '.per_second.png'
        average_response_name = output_name + '.average.png'
        apdex_name = output_name + '.apdex.png'
        per_second_path = gnuplot_scriptpath(report_dir, per_second_name)
        average_response_path = gnuplot_scriptpath(report_dir, average_response_name)
        apdex_path = gnuplot_scriptpath(report_dir, apdex_name)
        gplot_path = str(os.path.join(report_dir, output_name + '.gplot'))
        data_path = gnuplot_scriptpath(report_dir, output_name + '.data')

        labels = ['CUs', 'PS', 'Apdex*', 'AVG']
        data = []

        cycles = [int(v) for v in self.reports_data[0][key]['CUs']]

        for report_idx, report_data in enumerate(self.reports_data):
            for idx in range(len(cycles)):
                values = [report_idx]
                for column_name in labels:
                    values.append(report_data[key][column_name][idx])
                data.append(values)
            data.append(None)

        with open(data_path, 'w') as data_file:
            data_file.write(render_template(
                'gnuplot/data.mako',
                labels=labels,
                data=data
            ))

        with open(gplot_path, 'w') as gplot_file:
            gplot_file.write(render_template(
                'gnuplot/trend.mako',
                per_second_path=per_second_path,
                average_response_path=average_response_path,
                apdex_path=apdex_path,
                use_xticlabels=not strictly_monotonic(cycles),
                data_path=data_path,
                key=key,
                column_names=labels,
                reports_name=self.reports_name,
                labels=[metadata.get('label') for metadata in self.reports_metadata],
                max_cus=max(cycles),
            ))
        gnuplot(gplot_path)

        return (per_second_name, average_response_name, apdex_name)