def DidRunTest(self, browser, results): # Calculate geometric mean as the total for the combined tests. scores = [] for result in results.page_results: scores.append(result['Score'].output_value) total = statistics.GeometricMean(scores) results.AddSummary('Score', 'score', total, 'Total')
def DidRunTest(self, browser, results): # Calculate geometric mean as the total for the combined tests. combined = merge_values.MergeLikeValuesFromDifferentPages( results.all_page_specific_values, group_by_name_suffix=True) combined_score = [x for x in combined if x.name == 'Score'][0] total = statistics.GeometricMean(combined_score.values) results.AddSummary('Score', 'score', total, 'Total')
def MeasurePage(self, _, tab, results): tab.WaitForJavaScriptExpression( 'completed && !document.getElementById("progress-bar-container")', 300) results_log = tab.EvaluateJavaScript('__results') all_scores = [] for output in results_log: # Split the results into score and test name. # results log e.g., "Richards: 18343" score_and_name = output.split(': ', 2) assert len(score_and_name) == 2, \ 'Unexpected result format "%s"' % score_and_name name = score_and_name[0] score = int(score_and_name[1]) results.Add(name, 'score', score, data_type='unimportant') # Collect all test scores to compute geometric mean. all_scores.append(score) total = statistics.GeometricMean(all_scores) results.AddSummary('Score', 'score', total, chart_name='Total')