示例#1
0
    def run_tests(self, csv_queue):
        """
        execute the whole benchmark, including initialization, warmup and
        benchmark runs
        """

        # derive configuration for the CPU count / RAM size
        configs = PgBench._configure(cpu_count(), available_ram())

        results = {'ro': {}, 'rw': {}}  #ro:read only  rw:read-write
        j = 0
        for config in configs:
            scale = config['scale']

            if scale not in results['ro']:
                results['ro'][scale] = {}
            if scale not in results['rw']:
                results['rw'][scale] = {}
            #print(results)

            # init for the dataset scale and warmup
            self._init(scale)

            warmup = self._run('w%d' % j, scale, self._duration, cpu_count(),
                               cpu_count())
            j += 1

            # read-only & read-write
            for ro in [True, False]:
                if ro:
                    tag = 'ro'
                else:
                    tag = 'rw'

                for i in range(self._runs):
                    log("pgbench: %s run=%d" % (tag, i))

                    for clients in config['clients']:
                        if clients not in results[tag][scale]:
                            results[tag][scale][clients] = {}
                            results[tag][scale][clients]['results'] = []

                        r = self._run(i, scale, self._duration, clients,
                                      clients, ro, True, csv_queue)
                        r.update({'run': i})
                        results[tag][scale][clients]['results'].append(r)

                        tps = []
                        for result in results[tag][scale][clients]['results']:
                            tps.append(float(result['tps']))
                        results[tag][scale][clients]['metric'] = mean(tps)
                        results[tag][scale][clients]['median'] = median(tps)
                        results[tag][scale][clients]['std'] = std(tps)

        self._results['pgbench'] = results
        return self._results
示例#2
0
    def run_tests(self, csv_queue):
        """
        execute the whole benchmark, including initialization, warmup and
        benchmark runs
        """

        # derive configuration for the CPU count / RAM size
        configs = PgBench._configure(cpu_count(), available_ram())

        info = {}
        results = []
        result = {}

        configuration = {}

        j = 0
        for config in configs:
            info['clients'] = config['clients']
            scale = config['scale']

            # init for the dataset scale and warmup
            self._init(scale)

            warmup = self._run('w%d' % j, scale, self._duration, cpu_count(),
                               cpu_count())
            j += 1

            # read-only & read-write
            for ro in [True, False]:
                if ro:
                    tag = 'ro'
                else:
                    tag = 'rw'

                for i in range(self._runs):
                    log("pgbench: %s run=%d" % (tag, i))

                    for clients in config['clients']:
                        if clients not in results:
                            result['clients'] = clients

                        r = self._run(i, scale, self._duration, clients,
                                      clients, ro, True, csv_queue)

                        r.update({'run': i})
                        results.append(r)

        info['runs'] = results

        self._results['pgbench'] = info
        return self._results
    def run_tests(self, csv_queue, benchmark_options=None):
        """
        execute the whole benchmark, including initialization, warmup and
        benchmark runs
        """

        # derive configuration for the CPU count / RAM size
        # if there is benchmark setting in settings.py, take it and use,
        # otherwise use the default one
        configs = []
        if benchmark_options:
            configs.append(benchmark_options)
        else:
            configs = PgBench._configure(cpu_count(), available_ram())

        results = {'ro': {}, 'rw': {}, 'customeScript': {}}
        j = 0
        for config in configs:
            scale = config['scale']

            if scale not in results['ro']:
                results['ro'][scale] = {}
            if scale not in results['rw']:
                results['rw'][scale] = {}
            # if scale not in results['customeScript']:
            # results['customeScript'][scale] = {}

            # init for the dataset scale and warmup
            self._init(scale)

            warmup = self._run('w%d' % j, scale, self._duration, cpu_count(),
                               cpu_count())
            j += 1

            # read-only & read-write
            for ro in [True, False]:
                if ro:
                    tag = 'ro'
                else:
                    tag = 'rw'

                for i in range(self._runs):
                    log("pgbench: %s run=%d" % (tag, i))

                    for clients in config['clients']:
                        if clients not in results[tag][scale]:
                            results[tag][scale][clients] = {}
                            results[tag][scale][clients]['results'] = []

                        r = self._run(i, scale, self._duration, clients,
                                      clients, ro, True, csv_queue)
                        r.update({'run': i})
                        results[tag][scale][clients]['results'].append(r)

                        tps = []
                        for result in results[tag][scale][clients]['results']:
                            tps.append(float(result['tps']))
                        results[tag][scale][clients]['metric'] = mean(tps)
                        results[tag][scale][clients]['median'] = median(tps)
                        results[tag][scale][clients]['std'] = std(tps)
        # todo add cmmand
        # args = ['pgbench', '-c', str(nclients), '-j', str(njobs), '-T',
        #         str(duration)]

        script = ScriptCollector(scriptdirpath=SCRIPTS_DIR,
                                 env=self._env,
                                 dbname=self._dbname)
        if script.hasScript():
            start = time.time()
            scriptResult = script.run_custem_script()

            print('scriptResult   ')
            print(scriptResult)
            end = time.time()
            r = PgBench._parse_results(scriptResult[1])
            # r.update({'customeScript': read_only})
            # results[tag][scale][clients]['results'].append(r)
            r.update({'start': start, 'end': end})

            results['customeScript']['results'] = []
            results['customeScript']['results'].append(r)
            tps = []
            for result in results['customeScript']['results']:
                tps.append(float(result['tps']))
            results['customeScript']['metric'] = mean(tps)
            results['customeScript']['median'] = median(tps)
            results['customeScript']['std'] = std(tps)

            results['customeScript']['scriptList'] = script.getScriptListJson()

        self._results['pgbench'] = results
        return self._results