collect_experiment_data_odd_even_session.sh revision e93f47d88b6af945db2953f5663a591b9994a92c
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 statistics 7# for odd/even profile collection session ids. 8# The data is collected for an odd or even collection session id. 9 10set -e 11 12if [ $# -lt 7 ]; then 13 echo "Usage: collect_validation_data.sh cwp_table board board_arch " \ 14 "Chrome_OS_release odd_even inclusive_output_file " \ 15 "pairwise_inclusive_output_file" 16 exit 1 17fi 18 19readonly TABLE=$1 20readonly INCLUSIVE_OUTPUT_FILE=$6 21readonly PAIRWISE_INCLUSIVE_OUTPUT_FILE=$7 22readonly PERIODIC_COLLECTION=1 23readonly WHERE_CLAUSE_SPECIFICATIONS="meta.cros.board = '$2' AND " \ 24 "meta.cros.cpu_architecture = '$3' AND " \ 25 "meta.cros.chrome_version LIKE '%$4%' AND "\ 26 "meta.cros.collection_info.trigger_event = $PERIODIC_COLLECTION AND " \ 27 "MOD(session.id, 2) = $5" 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 "set sql_dialect GoogleSQL; 32 33SELECT 34 replace(frame.function_name, \", \", \"; \") AS function, 35 frame.filename AS file, 36 frame.load_module_path AS dso, 37 SUM(frame.inclusive_count) AS inclusive_count, 38 SUM(frame.inclusive_count)/ANY_VALUE(total.value) AS inclusive_count_fraction 39FROM 40 $TABLE table, 41 table.frame frame 42CROSS JOIN ( 43 SELECT 44 SUM(count) AS value 45 FROM $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 --output=csv > "$INCLUSIVE_OUTPUT_FILE" 60 61# Collects the pair of parent and child functions, with the file and object 62# where the child function is declared and the inclusive count fraction of the 63# pair out of the total amount of inclusive count values. 64echo "set sql_dialect GoogleSQL; 65 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 79 $TABLE 80 WHERE 81 $WHERE_CLAUSE_SPECIFICATIONS 82) AS total 83WHERE 84 $WHERE_CLAUSE_SPECIFICATIONS 85GROUP BY 86 parent_child_functions, 87 child_function_file, 88 child_function_dso 89HAVING 90 inclusive_count > 0.0 91ORDER BY 92 inclusive_count DESC; 93" | dremel --output=csv > "$PAIRWISE_INCLUSIVE_OUTPUT_FILE" 94