blob: 900e582bf503bb78c02089000c94fcf19b18ffb0 [file] [log] [blame]
Evelina Dumitrescudaddec92016-09-15 16:00:04 -07001#!/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
Evelina Dumitrescu45478f92016-10-08 02:04:13 -070012if [ $# -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 Dumitrescudaddec92016-09-15 16:00:04 -070016 exit 1
17fi
18
19readonly TABLE=$1
Evelina Dumitrescu45478f92016-10-08 02:04:13 -070020readonly INCLUSIVE_OUTPUT_FILE=$7
21readonly PAIRWISE_INCLUSIVE_OUTPUT_FILE=$8
Evelina Dumitrescudaddec92016-09-15 16:00:04 -070022readonly PERIODIC_COLLECTION=1
Evelina Dumitrescu45478f92016-10-08 02:04:13 -070023WHERE_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 Dumitrescudaddec92016-09-15 16:00:04 -070030
31# Collects the function, with its file, the object and inclusive count
32# fraction out of the total amount of inclusive count values.
Evelina Dumitrescu45478f92016-10-08 02:04:13 -070033echo "
Evelina Dumitrescudaddec92016-09-15 16:00:04 -070034SELECT
35 replace(frame.function_name, \", \", \"; \") AS function,
36 frame.filename AS file,
37 frame.load_module_path AS dso,
Evelina Dumitrescue93f47d2016-09-28 21:23:41 -070038 SUM(frame.inclusive_count) AS inclusive_count,
Evelina Dumitrescudaddec92016-09-15 16:00:04 -070039 SUM(frame.inclusive_count)/ANY_VALUE(total.value) AS inclusive_count_fraction
40FROM
41 $TABLE table,
42 table.frame frame
43CROSS JOIN (
44 SELECT
45 SUM(count) AS value
46 FROM $TABLE
47 WHERE
48 $WHERE_CLAUSE_SPECIFICATIONS
49) AS total
50WHERE
51 $WHERE_CLAUSE_SPECIFICATIONS
52GROUP BY
53 function,
54 file,
55 dso
56HAVING
57 inclusive_count_fraction > 0.0
58ORDER BY
59 inclusive_count_fraction DESC;
Evelina Dumitrescu45478f92016-10-08 02:04:13 -070060" | dremel --sql_dialect=GoogleSQL --min_completion_ratio=1.0 --output=csv > \
61 "$INCLUSIVE_OUTPUT_FILE"
Evelina Dumitrescudaddec92016-09-15 16:00:04 -070062
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 Dumitrescu45478f92016-10-08 02:04:13 -070066echo "
Evelina Dumitrescudaddec92016-09-15 16:00:04 -070067SELECT
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 Dumitrescue93f47d2016-09-28 21:23:41 -070072 SUM(frame.inclusive_count)/ANY_VALUE(total.value) AS inclusive_count
Evelina Dumitrescudaddec92016-09-15 16:00:04 -070073FROM
74 $TABLE table,
75 table.frame frame
76CROSS JOIN (
77 SELECT
78 SUM(count) AS value
79 FROM
80 $TABLE
81 WHERE
82 $WHERE_CLAUSE_SPECIFICATIONS
83) AS total
84WHERE
85 $WHERE_CLAUSE_SPECIFICATIONS
86GROUP BY
87 parent_child_functions,
88 child_function_file,
89 child_function_dso
90HAVING
Evelina Dumitrescue93f47d2016-09-28 21:23:41 -070091 inclusive_count > 0.0
Evelina Dumitrescudaddec92016-09-15 16:00:04 -070092ORDER BY
Evelina Dumitrescue93f47d2016-09-28 21:23:41 -070093 inclusive_count DESC;
Evelina Dumitrescu45478f92016-10-08 02:04:13 -070094" | dremel --sql_dialect=GoogleSQL --min_completion_ratio=1.0 --output=csv > \
95 "$PAIRWISE_INCLUSIVE_OUTPUT_FILE"