Пример #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
    def getCodeSpeedClient(cls):
        if cls.__client is None:

            from codespeed_client import Client

            # kwargs passed to constructor are defaults

            cls.__client = Client(cls._getHost(),
                                  environment=cls._getEnvironment(),
                                  project=cls._getProject())

        return cls.__client
Пример #3
0
    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()