예제 #1
0
def send_metrics(metrics):
    # print("Sending metrics:")
    # print(metrics)
    client = Client('https://speed.wasmer.io', environment='local-machine-1')
    results = []
    for metric in metrics:
        stats = metric['stats']
        seconds = stats['average'] / 1000000000
        min = stats['min'] / 1000000000
        max = stats['max'] / 1000000000
        stdev = stats['stdev'] / 1000000000
        project = BACKEND_TO_PROJECT[metric['backend']]
        commit_id = get_commit_id(project)
        result = {
            'executable': metric['backend'],
            'commitid': commit_id,
            'min': min,
            'max': max,
            'std_dev': stdev,
            'benchmark': metric['benchmark'],
            'result_value': seconds,
            'project': project
        }
        results.append(result)
        client.add_result(**result)
    print('Sending results:')
    print(results)
    client.upload_results()
예제 #2
0
파일: benchmark.py 프로젝트: onitu/onitu
    def upload_results(self,
                       name,
                       host,
                       environment,
                       project,
                       commitid,
                       branch
                       ):
        """upload the results to a codespeed instance
        Https://github.com/tobami/codespeed/
        """
        # kwargs list: environment, project, benchmark, branch, commitid,
        # result_date, result_value, max, min,
        # std_dev, revision_date, executable,

        # kwargs passed to constructor are defaults
        client = Client(
            host,
            environment=environment,
            project=project,
            commitid=commitid,
            branch=branch
        )

        # kwargs passed to add_result overwrite defaults
        for result in self._results:
            n = '{}-{}'.format(name.replace(' ', '_'),
                               result[len(self._prefix):])
            res = self._results[result] / 1000
            client.add_result(
                benchmark=n,
                result_value=res
            )

        # upload all results in one request
        client.upload_results()
예제 #3
0
class CodeSpeedReporter(Reporter):
    """Reporter for CodeSpeed."""

    verbose = True

    def __init__(self, root_url, less_is_better=True, **kwargs):
        self.less_is_better = less_is_better

        try:
            from codespeed_client import Client
        except ImportError as e:
            msg = str(e) + '\n\nPlease install codespeed_client package: pip install codespeed_client'
            raise ImportError(msg)

        self.client = Client(root_url, **kwargs)

    def after_benchmark(self, project, benchmark, data_label, results):
        if self.less_is_better:
            min_value, max_value = self.min_max_time_per_call(results)  # less is better - default for new CodeSpeed benchmarks
            value = min_value
        else:
            min_value, max_value = self.min_max_speed(results)
            value = max_value

        project = project.replace('BenchmarkCase', '')
        benchmark = benchmark.replace('benchmark_', '')
        # TODO: use data
        self.client.add_result(project=project, benchmark=benchmark, result_value=value, min=min_value, max=max_value)

    def after_run(self):
        from codespeed_client import UploadError

        if self.verbose:
            print("Uploading %d results to %s... " % (len(self.client.data), self.client.url), end='', file=sys.stderr)

        try:
            code, body = self.client.upload_results()
        except UploadError as e:
            code, body = e.errno, e.strerror
            raise
        finally:
            if self.verbose:
                print("%s - %s" % (code, body), file=sys.stderr)