def test_get_queries_geomean_performance_samples_passing(self): b_p = agg.EdwBenchmarkPerformance(total_iterations=2, expected_queries=[Q1_NAME, Q2_NAME]) i1_p = agg.EdwPowerIterationPerformance('1', 2) i1_p.add_query_performance(Q1_NAME, 1.0, {'job_id': 'q1_i1_job_id'}) i1_p.add_query_performance(Q2_NAME, 2.0, {'job_id': 'q2_i1_job_id'}) b_p.add_power_iteration_performance(i1_p) i2_p = agg.EdwPowerIterationPerformance('2', 2) i2_p.add_query_performance(Q1_NAME, 3.0, {'job_id': 'q1_i2_job_id'}) i2_p.add_query_performance(Q2_NAME, 4.0, {}) b_p.add_power_iteration_performance(i2_p) actual_sample_list = b_p.get_queries_geomean_performance_samples( {'benchmark_name': 'b_name'}) self.assertEqual(len(actual_sample_list), 3) self.assertSameElements([x.metric for x in actual_sample_list], [ 'edw_iteration_geomean_time', 'edw_iteration_geomean_time', 'edw_aggregated_geomean' ]) raw_samples = list( filter(lambda x: x.metric == 'edw_iteration_geomean_time', actual_sample_list)) actual_raw_samples_values = [x.value for x in raw_samples] expected_raw_samples_values = [ agg.geometric_mean([1.0, 2.0]), agg.geometric_mean([3.0, 4.0]) ] self.assertSameElements(actual_raw_samples_values, expected_raw_samples_values) aggregated_sample = list( filter(lambda x: x.metric == 'edw_aggregated_geomean', actual_sample_list))[0] self.assertEqual( aggregated_sample.value, agg.geometric_mean([(1.0 + 3.0) / 2, (2.0 + 4.0) / 2]))
def test_get_aggregated_geomean_performance_sample_passing(self): b_p = agg.EdwBenchmarkPerformance( total_iterations=2, expected_suite_queries=[Q1_NAME, Q2_NAME]) s1_p = agg.EdwSuitePerformance('suite_name', 'suite_seq_1', 2) q11_p = agg.EdwQueryPerformance(Q1_NAME, 1.0, {'job_id': 'q1_s1_job_id'}) s1_p.add_query_performance(q11_p) q12_p = agg.EdwQueryPerformance(Q2_NAME, 2.0, {'job_id': 'q2_s1_job_id'}) s1_p.add_query_performance(q12_p) b_p.add_suite_performance('suite_seq_1', s1_p) s2_p = agg.EdwSuitePerformance('suite_name', 'suite_seq_2', 2) q21_p = agg.EdwQueryPerformance(Q1_NAME, 3.0, {'job_id': 'q1_s2_job_id'}) s2_p.add_query_performance(q21_p) q22_p = agg.EdwQueryPerformance(Q2_NAME, 4.0, {}) s2_p.add_query_performance(q22_p) b_p.add_suite_performance('suite_seq_2', s2_p) actual_sample = b_p.get_aggregated_geomean_performance_sample( {'benchmark_name': 'b_name'}) self.assertEqual(actual_sample.metric, 'edw_aggregated_geomean') self.assertEqual(actual_sample.value, agg.geometric_mean([(1.0 + 3.0) / 2, (2.0 + 4.0) / 2])) self.assertEqual(actual_sample.unit, 'seconds') expected_metadata = { 'benchmark_name': 'b_name', 'intra_query_aggregation_method': 'mean', 'inter_query_aggregation_method': 'geomean' } self.assertDictEqual(actual_sample.metadata, expected_metadata)
def test_get_queries_geomean_performance_samples_passing(self): b_p = agg.EdwBenchmarkPerformance(total_iterations=2) s1_p = agg.EdwSuitePerformance('suite_name', 'suite_seq_1', 2) q11_p = agg.EdwQueryPerformance(Q1_NAME, 1.0, {'job_id': 'q1_s1_job_id'}) s1_p.add_query_performance(q11_p) q12_p = agg.EdwQueryPerformance(Q2_NAME, 2.0, {'job_id': 'q2_s1_job_id'}) s1_p.add_query_performance(q12_p) b_p.add_suite_performance('suite_seq_1', s1_p) s2_p = agg.EdwSuitePerformance('suite_name', 'suite_seq_2', 2) q21_p = agg.EdwQueryPerformance(Q1_NAME, 3.0, {'job_id': 'q1_s2_job_id'}) s2_p.add_query_performance(q21_p) q22_p = agg.EdwQueryPerformance(Q2_NAME, 4.0, {}) s2_p.add_query_performance(q22_p) b_p.add_suite_performance('suite_seq_2', s2_p) actual_sample_list = b_p.get_queries_geomean_performance_samples( {'benchmark_name': 'b_name'}, [Q1_NAME, Q2_NAME]) self.assertEqual(len(actual_sample_list), 3) self.assertSameElements([x.metric for x in actual_sample_list], [ 'edw_raw_geomean_time', 'edw_raw_geomean_time', 'edw_aggregated_geomean' ]) raw_samples = list( filter(lambda x: x.metric == 'edw_raw_geomean_time', actual_sample_list)) actual_raw_samples_values = [x.value for x in raw_samples] expected_raw_samples_values = [ agg.geometric_mean([1.0, 2.0]), agg.geometric_mean([3.0, 4.0]) ] self.assertSameElements(actual_raw_samples_values, expected_raw_samples_values) aggregated_sample = list( filter(lambda x: x.metric == 'edw_aggregated_geomean', actual_sample_list))[0] self.assertEqual( aggregated_sample.value, agg.geometric_mean([(1.0 + 3.0) / 2, (2.0 + 4.0) / 2]))
def test_get_queries_geomean_performance(self): i_p = agg.EdwPowerIterationPerformance('1', 2) i_p.add_query_performance(Q1_NAME, Q1_PERFORMANCE, METADATA_EMPTY) i_p.add_query_performance(Q2_NAME, Q2_PERFORMANCE, METADATA_EMPTY) iteration_geomean_performance_sample = i_p.get_queries_geomean_performance_sample( expected_queries=[Q1_NAME, Q2_NAME], metadata=METADATA_EMPTY) self.assertEqual(iteration_geomean_performance_sample.metric, 'edw_iteration_geomean_time') self.assertEqual(iteration_geomean_performance_sample.value, agg.geometric_mean([Q1_PERFORMANCE, Q2_PERFORMANCE])) self.assertEqual(iteration_geomean_performance_sample.unit, SECS) self.assertDictEqual(iteration_geomean_performance_sample.metadata, METADATA_EMPTY)
def test_get_queries_geomean_performance(self): s_p = agg.EdwSuitePerformance('suite_name', 'suite_seq', 2) q1_p = agg.EdwQueryPerformance(Q1_NAME, Q1_PERFORMANCE, METADATA_EMPTY) s_p.add_query_performance(q1_p) q2_p = agg.EdwQueryPerformance(Q2_NAME, Q2_PERFORMANCE, METADATA_EMPTY) s_p.add_query_performance(q2_p) suite_wall_time_performance_sample = s_p.get_queries_geomean_performance_sample( METADATA_EMPTY) self.assertEqual(suite_wall_time_performance_sample.metric, 'edw_raw_geomean_time') self.assertEqual(suite_wall_time_performance_sample.value, agg.geometric_mean([Q1_PERFORMANCE, Q2_PERFORMANCE])) self.assertEqual(suite_wall_time_performance_sample.unit, SECS) self.assertDictEqual(suite_wall_time_performance_sample.metadata, METADATA_EMPTY)
def test_get_aggregated_geomean_performance_sample_passing(self): b_p = agg.EdwBenchmarkPerformance(total_iterations=2, expected_queries=[Q1_NAME, Q2_NAME]) i1_p = agg.EdwPowerIterationPerformance('1', 2) i1_p.add_query_performance(Q1_NAME, 1.0, {'job_id': 'q1_i1_job_id'}) i1_p.add_query_performance(Q2_NAME, 2.0, {'job_id': 'q2_i1_job_id'}) b_p.add_power_iteration_performance(i1_p) i2_p = agg.EdwPowerIterationPerformance('2', 2) i2_p.add_query_performance(Q1_NAME, 3.0, {'job_id': 'q1_i2_job_id'}) i2_p.add_query_performance(Q2_NAME, 4.0, {}) b_p.add_power_iteration_performance(i2_p) actual_sample = b_p.get_aggregated_geomean_performance_sample( {'benchmark_name': 'b_name'}) self.assertEqual(actual_sample.metric, 'edw_aggregated_geomean') self.assertEqual( actual_sample.value, agg.geometric_mean([(1.0 + 3.0) / 2, (2.0 + 4.0) / 2])) self.assertEqual(actual_sample.unit, 'seconds') expected_metadata = { 'benchmark_name': 'b_name', 'intra_query_aggregation_method': 'mean', 'inter_query_aggregation_method': 'geomean' } self.assertDictEqual(actual_sample.metadata, expected_metadata)
def test_geometric_mean_no_values(self): performance_iterable = [] with self.assertRaises(agg.EdwPerformanceAggregationError): agg.geometric_mean(performance_iterable)
def test_geometric_mean_include_negative_value(self): performance_iterable = [1.0, -2.0, 3.0] with self.assertRaises(agg.EdwPerformanceAggregationError): agg.geometric_mean(performance_iterable)
def test_geometric_mean_valid_values(self): performance_iterable = [1.0, 2.0, 3.0] expected_geometric_mean = agg.geometric_mean(performance_iterable) self.assertEqual('%.2f' % expected_geometric_mean, '1.82')