collect_experiment_data.sh revision 45478f9b3c3d0068eed177df6524c0e7f00a736c
1#!/bin/bash 2 3# Copyright 2016 The Chromium OS Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6# Uses Dremel queries to collect the inclusive and pairwise inclusive 7# statistics. 8 9set -e 10 11if [ "$#" -ne 7 ]; then 12 echo "USAGE: collect_experiment_data.sh cwp_table board board_arch " \ 13 "Chrome_version Chrome_OS_version inclusive_output_file " \ 14 "pairwise_inclusive_output_file" 15 exit 1 16fi 17 18readonly TABLE=$1 19readonly INCLUSIVE_OUTPUT_FILE=$6 20readonly PAIRWISE_INCLUSIVE_OUTPUT_FILE=$7 21readonly PERIODIC_COLLECTION=1 22readonly WHERE_CLAUSE_SPECIFICATIONS="meta.cros.board = '$2' AND \ 23 meta.cros.cpu_architecture = '$3' AND \ 24 meta.cros.chrome_version LIKE '%$4%' AND \ 25 meta.cros.version = '$5' AND \ 26 meta.cros.collection_info.trigger_event = $PERIODIC_COLLECTION AND \ 27 session.total_count > 2000" 28 29# Collects the function, with its file, the object and inclusive count 30# fraction out of the total amount of inclusive count values. 31echo " 32SELECT 33 replace(frame.function_name, \", \", \"; \") AS function, 34 frame.filename AS file, 35 frame.load_module_path AS dso, 36 SUM(frame.inclusive_count) AS inclusive_count, 37 SUM(frame.inclusive_count)/ANY_VALUE(total.value) AS inclusive_count_fraction 38FROM 39 $TABLE table, 40 table.frame frame 41CROSS JOIN ( 42 SELECT 43 SUM(count) AS value 44 FROM 45 $TABLE 46 WHERE 47 $WHERE_CLAUSE_SPECIFICATIONS 48) AS total 49WHERE 50 $WHERE_CLAUSE_SPECIFICATIONS 51GROUP BY 52 function, 53 file, 54 dso 55HAVING 56 inclusive_count_fraction > 0.0 57ORDER BY 58 inclusive_count_fraction DESC; 59" | dremel --sql_dialect=GoogleSQL --min_completion_ratio=1.0 --output=csv \ 60 > "$INCLUSIVE_OUTPUT_FILE" 61 62# Collects the pair of parent and child functions, with the file and object 63# where the child function is declared and the inclusive count fraction of the 64# pair out of the total amount of inclusive count values. 65echo " 66SELECT 67 CONCAT(replace(frame.parent_function_name, \", \", \"; \"), \";;\", 68 replace(frame.function_name, \", \", \"; \")) AS parent_child_functions, 69 frame.filename AS child_function_file, 70 frame.load_module_path AS child_function_dso, 71 SUM(frame.inclusive_count)/ANY_VALUE(total.value) AS inclusive_count 72FROM 73 $TABLE table, 74 table.frame frame 75CROSS JOIN ( 76 SELECT 77 SUM(count) AS value 78 FROM $TABLE 79 WHERE 80 $WHERE_CLAUSE_SPECIFICATIONS 81) AS total 82WHERE 83 $WHERE_CLAUSE_SPECIFICATIONS 84GROUP BY 85 parent_child_functions, 86 child_function_file, 87 child_function_dso 88HAVING 89 inclusive_count > 0.0 90ORDER BY 91 inclusive_count DESC; 92" | dremel --sql_dialect=GoogleSQL --min_completion_ratio=1.0 --output=csv > \ 93 "$PAIRWISE_INCLUSIVE_OUTPUT_FILE" 94