Exemple #1
0
    def plot(cls, params_dict):
        try:
            params = PlotParameters(params_dict)
        except PlotError as e:
            raise PlotError('Invalid nodes or bench parameters', e)

        # Aggregate the logs.
        LogAggregator(params.max_latency).print()

        # Load the aggregated log files.
        robustness_files, latency_files, tps_files = [], [], []
        tx_size = params.tx_size
        
        for f in params.faults:
            for n in params.nodes:
                robustness_files += glob(
                    PathMaker.agg_file('robustness', n, 'x', tx_size, f, 'any')
                )
                latency_files += glob(
                    PathMaker.agg_file('latency', n, 'any', tx_size, f, 'any')
                )
            for l in params.max_latency:
                tps_files += glob(
                    PathMaker.agg_file('tps', 'x', 'any', tx_size, f, l)
                )

        # Make the plots.
        cls.plot_robustness(robustness_files)
        cls.plot_latency(latency_files)
        cls.plot_tps(tps_files)
Exemple #2
0
    def print(self):
        if not os.path.exists(PathMaker.plots_path()):
            os.makedirs(PathMaker.plots_path())

        results = [
            self._print_latency(),
            self._print_tps(),
            self._print_robustness()
        ]
        for records in results:
            for setup, values in records.items():
                data = '\n'.join(f' Variable value: X={x}\n{y}'
                                 for x, y in values)
                string = ('\n'
                          '-----------------------------------------\n'
                          ' RESULTS:\n'
                          '-----------------------------------------\n'
                          f'{setup}'
                          '\n'
                          f'{data}'
                          '-----------------------------------------\n')
                filename = PathMaker.agg_file(setup.nodes,
                                              setup.rate,
                                              setup.tx_size,
                                              max_latency=setup.max_latency)
                with open(filename, 'w') as f:
                    f.write(string)
Exemple #3
0
    def plot_tps(cls, z_axis):
        assert hasattr(z_axis, '__call__')
        x_label = 'Committee size'
        y_label = ['Throughput (tx/s)', 'Throughput (MB/s)']

        files = glob(PathMaker.agg_file('x', 'any', r'*', r'*'))
        ploter = cls(files)
        ploter._plot(x_label, y_label, ploter._tps, z_axis, 'tps')
Exemple #4
0
    def plot_latency(cls, z_axis):
        assert hasattr(z_axis, '__call__')
        x_label = 'Throughput (tx/s)'
        y_label = ['Latency (ms)']

        files = glob(PathMaker.agg_file(r'[0-9]*', 'any', r'*', 'any'))
        ploter = cls(files)
        ploter._plot(x_label, y_label, ploter._latency, z_axis, 'latency')
Exemple #5
0
    def plot_robustness(cls, z_axis):
        assert hasattr(z_axis, '__call__')
        x_label = 'Input rate (tx/s)'
        y_label = ['Throughput (tx/s)', 'Throughput (MB/s)']

        files = glob(PathMaker.agg_file(r'[0-9]*', 'x', r'*', 'any'))
        ploter = cls(files)
        ploter._plot(x_label, y_label, ploter._tps, z_axis, 'robustness')