Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 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 | |
| 10 | set -e |
| 11 | |
Evelina Dumitrescu | 45478f9 | 2016-10-08 02:04:13 -0700 | [diff] [blame] | 12 | if [ $# -lt 8 ]; then |
| 13 | echo "Usage: collect_experiment_data_odd_even_session.sh cwp_table board " \ |
| 14 | "board_arch Chrome_version Chrome_OS_version odd_even " \ |
| 15 | "inclusive_output_file pairwise_inclusive_output_file" |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | readonly TABLE=$1 |
Evelina Dumitrescu | 45478f9 | 2016-10-08 02:04:13 -0700 | [diff] [blame] | 20 | readonly INCLUSIVE_OUTPUT_FILE=$7 |
| 21 | readonly PAIRWISE_INCLUSIVE_OUTPUT_FILE=$8 |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 22 | readonly PERIODIC_COLLECTION=1 |
Evelina Dumitrescu | 45478f9 | 2016-10-08 02:04:13 -0700 | [diff] [blame] | 23 | 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.version = '$5' AND \ |
| 27 | meta.cros.collection_info.trigger_event = $PERIODIC_COLLECTION AND \ |
| 28 | MOD(session.id, 2) = $6 AND \ |
| 29 | session.total_count > 2000" |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 30 | |
| 31 | # Collects the function, with its file, the object and inclusive count |
| 32 | # fraction out of the total amount of inclusive count values. |
Evelina Dumitrescu | 45478f9 | 2016-10-08 02:04:13 -0700 | [diff] [blame] | 33 | echo " |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 34 | SELECT |
| 35 | replace(frame.function_name, \", \", \"; \") AS function, |
| 36 | frame.filename AS file, |
| 37 | frame.load_module_path AS dso, |
Evelina Dumitrescu | e93f47d | 2016-09-28 21:23:41 -0700 | [diff] [blame] | 38 | SUM(frame.inclusive_count) AS inclusive_count, |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 39 | SUM(frame.inclusive_count)/ANY_VALUE(total.value) AS inclusive_count_fraction |
| 40 | FROM |
| 41 | $TABLE table, |
| 42 | table.frame frame |
| 43 | CROSS JOIN ( |
| 44 | SELECT |
| 45 | SUM(count) AS value |
| 46 | FROM $TABLE |
| 47 | WHERE |
| 48 | $WHERE_CLAUSE_SPECIFICATIONS |
| 49 | ) AS total |
| 50 | WHERE |
| 51 | $WHERE_CLAUSE_SPECIFICATIONS |
| 52 | GROUP BY |
| 53 | function, |
| 54 | file, |
| 55 | dso |
| 56 | HAVING |
| 57 | inclusive_count_fraction > 0.0 |
| 58 | ORDER BY |
| 59 | inclusive_count_fraction DESC; |
Evelina Dumitrescu | 45478f9 | 2016-10-08 02:04:13 -0700 | [diff] [blame] | 60 | " | dremel --sql_dialect=GoogleSQL --min_completion_ratio=1.0 --output=csv > \ |
| 61 | "$INCLUSIVE_OUTPUT_FILE" |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 62 | |
| 63 | # Collects the pair of parent and child functions, with the file and object |
| 64 | # where the child function is declared and the inclusive count fraction of the |
| 65 | # pair out of the total amount of inclusive count values. |
Evelina Dumitrescu | 45478f9 | 2016-10-08 02:04:13 -0700 | [diff] [blame] | 66 | echo " |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 67 | SELECT |
| 68 | CONCAT(replace(frame.parent_function_name, \", \", \"; \"), \";;\", |
| 69 | replace(frame.function_name, \", \", \"; \")) AS parent_child_functions, |
| 70 | frame.filename AS child_function_file, |
| 71 | frame.load_module_path AS child_function_dso, |
Evelina Dumitrescu | e93f47d | 2016-09-28 21:23:41 -0700 | [diff] [blame] | 72 | SUM(frame.inclusive_count)/ANY_VALUE(total.value) AS inclusive_count |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 73 | FROM |
| 74 | $TABLE table, |
| 75 | table.frame frame |
| 76 | CROSS JOIN ( |
| 77 | SELECT |
| 78 | SUM(count) AS value |
| 79 | FROM |
| 80 | $TABLE |
| 81 | WHERE |
| 82 | $WHERE_CLAUSE_SPECIFICATIONS |
| 83 | ) AS total |
| 84 | WHERE |
| 85 | $WHERE_CLAUSE_SPECIFICATIONS |
| 86 | GROUP BY |
| 87 | parent_child_functions, |
| 88 | child_function_file, |
| 89 | child_function_dso |
| 90 | HAVING |
Evelina Dumitrescu | e93f47d | 2016-09-28 21:23:41 -0700 | [diff] [blame] | 91 | inclusive_count > 0.0 |
Evelina Dumitrescu | daddec9 | 2016-09-15 16:00:04 -0700 | [diff] [blame] | 92 | ORDER BY |
Evelina Dumitrescu | e93f47d | 2016-09-28 21:23:41 -0700 | [diff] [blame] | 93 | inclusive_count DESC; |
Evelina Dumitrescu | 45478f9 | 2016-10-08 02:04:13 -0700 | [diff] [blame] | 94 | " | dremel --sql_dialect=GoogleSQL --min_completion_ratio=1.0 --output=csv > \ |
| 95 | "$PAIRWISE_INCLUSIVE_OUTPUT_FILE" |