On Tue, Nov 03, 2020 at 08:56:51PM +0800, Lu Weitao wrote:
On Tue, Nov 03, 2020 at 03:28:37PM +0800, Zhang Yuhang wrote:
On Tue, Nov 03, 2020 at 02:49:49PM +0800, Lu Weitao wrote:
compare values by each metrics based on groups matrices, and format compare result as echart data_set
background: For support compare with user-defined template feature, the work-flow of user-defined template feature: load_compare_template.yaml --> query_results(ES) ---> auto group jobs_list ---> create groups_matrices ---> compare_values by each metrics ---> format/show results
current patch is the step: compare_values by each metrics ---> format/show results
Signed-off-by: Lu Weitao luweitaobe@163.com
lib/compare_matrixes.rb | 107 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+)
diff --git a/lib/compare_matrixes.rb b/lib/compare_matrixes.rb index 078028a..7e6dfb1 100644 --- a/lib/compare_matrixes.rb +++ b/lib/compare_matrixes.rb @@ -399,8 +399,115 @@ def compare_group_matrices(group_matrices, options) result_str end
+# compare group_matrices with each dimension(matrix) of each group, +# and reorganize the result as group-metric-compare-values +# +# Input: groups_matrices +# { +# group_key_1 => { +# dimension_1 => matrix_1, (openeuler 20.03) +# dimension_2 => matrix_2, (openeuler 20.09) +# dimension_3 => matrix_3, (centos 7.6) +# }, +# group_key_2 => {...} +# } +# +# output: compare_metrics_values +# { +# group_key_1 => { +# metric_1 => { +# 'average' => { +# 'dimension_1' => xxx +# 'dimension_2' => xxx +# 'dimension_3' => xxx +# }, +# 'standard_deviation' => { +# 'dimension_1' => xxx +# 'dimension_2' => xxx +# 'dimension_3' => xxx +# }, +# 'change' => { +# 'dimension_2 vs dimension_1' => xxx +# 'dimension_3 vs dimension_1' => xxx +# 'dimension_3 vs dimension_2' => xxx +# } +# }, +# metric_2 => {...} +# } +# } +def compare_metrics_values(groups_matrices)
- metrics_compare_values = {}
- groups_matrices.each do |group_key, dimensions|
- metrics_compare_values[group_key] = get_metric_values(dimensions)
- end
- metrics_compare_values
+end
+def get_metric_values(dimensions)
- metrics_values = {}
- dimensions.each do |dim, matrix|
- matrix.each do |metric, values|
metrics_values[metric] ||= {}
metrics_values[metric]['average'] ||= {}
metrics_values[metric]['standard_deviation'] ||= {}
metric_value = get_values(values, true)
metrics_values[metric]['average'][dim] = metric_value[:average]
metrics_values[metric]['standard_deviation'][dim] = metric_value[:stddev]
- end
- end
- get_metric_change(metrics_values)
set_metric_change(metrics_values), maybe better. :)
这里会触发rubo warning 还是只能用get了
Thanks, Weitao
Could give the warning info?
Thanks, Zhang Yuhang