def _setup_reports(self, reports, test_name, num_threads):
     self.total_ops_per_sec = 0
     self.num_tests = len(reports)
     self.cber_hook.benchmark_reports[test_name] = cber._BenchrunEmbeddedThreadsReport()
     for rep in reports:
         self.cber_hook.benchmark_reports[test_name].add_report(num_threads, rep)
         self.total_ops_per_sec += rep["totalOps/s"]
     self.ops_per_sec = self.total_ops_per_sec / self.num_tests
     self.report = self.cber_hook._generate_perf_plugin_report()
 def _setup_reports(self, reports, test_name, num_threads):
     self.total_ops_per_sec = 0
     self.num_tests = len(reports)
     self.cber_hook.benchmark_reports[test_name] = cber._BenchrunEmbeddedThreadsReport()
     for rep in reports:
         self.cber_hook.benchmark_reports[test_name].add_report(num_threads, rep)
         self.total_ops_per_sec += rep["totalOps/s"]
     self.ops_per_sec = self.total_ops_per_sec / self.num_tests
     self.report = self.cber_hook._generate_perf_plugin_report()
    def test_generate_single_thread_perf_plugin_dict(self):
        thread_report = cber._BenchrunEmbeddedThreadsReport()
        thread_num = "1"
        thread_report.add_report(thread_num, _BM_REPORT_INSERT_1)
        perf_report = thread_report.generate_perf_plugin_dict()
        self.assertEqual(len(perf_report.keys()), 1)
        self.assertEqual(perf_report[thread_num]["ops_per_sec"], _BM_REPORT_INSERT_1["totalOps/s"])
        self.assertEqual(len(perf_report[thread_num]["ops_per_sec_values"]), 1)

        thread_report.add_report(thread_num, _BM_REPORT_INSERT_2)
        perf_report = thread_report.generate_perf_plugin_dict()
        self.assertEqual(len(perf_report.keys()), 1)
        ops_per_sec = (_BM_REPORT_INSERT_1["totalOps/s"] + _BM_REPORT_INSERT_2["totalOps/s"]) / 2
        self.assertEqual(perf_report[thread_num]["ops_per_sec"], ops_per_sec)
        self.assertEqual(len(perf_report[thread_num]["ops_per_sec_values"]), 2)
    def test_generate_single_thread_perf_plugin_dict(self):
        thread_report = cber._BenchrunEmbeddedThreadsReport()
        thread_num = "1"
        thread_report.add_report(thread_num, _BM_REPORT_INSERT_1)
        perf_report = thread_report.generate_perf_plugin_dict()
        self.assertEqual(len(list(perf_report.keys())), 1)
        self.assertEqual(perf_report[thread_num]["ops_per_sec"], _BM_REPORT_INSERT_1["totalOps/s"])
        self.assertEqual(len(perf_report[thread_num]["ops_per_sec_values"]), 1)

        thread_report.add_report(thread_num, _BM_REPORT_INSERT_2)
        perf_report = thread_report.generate_perf_plugin_dict()
        self.assertEqual(len(list(perf_report.keys())), 1)
        ops_per_sec = (_BM_REPORT_INSERT_1["totalOps/s"] + _BM_REPORT_INSERT_2["totalOps/s"]) / 2
        self.assertEqual(perf_report[thread_num]["ops_per_sec"], ops_per_sec)
        self.assertEqual(len(perf_report[thread_num]["ops_per_sec_values"]), 2)