• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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"
16  exit 1
17fi
18
19readonly TABLE=$1
20readonly INCLUSIVE_OUTPUT_FILE=$7
21readonly PAIRWISE_INCLUSIVE_OUTPUT_FILE=$8
22readonly PERIODIC_COLLECTION=1
23WHERE_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"
30
31# Collects the function, with its file, the object and inclusive count
32# fraction out of the total amount of inclusive count values.
33echo "
34SELECT
35  replace(frame.function_name, \", \", \"; \") AS function,
36  frame.filename AS file,
37  frame.load_module_path AS dso,
38  SUM(frame.inclusive_count) AS inclusive_count,
39  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;
60" | dremel --sql_dialect=GoogleSQL --min_completion_ratio=1.0 --output=csv > \
61  "$INCLUSIVE_OUTPUT_FILE"
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.
66echo "
67SELECT
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,
72  SUM(frame.inclusive_count)/ANY_VALUE(total.value) AS inclusive_count
73FROM
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
91  inclusive_count > 0.0
92ORDER BY
93  inclusive_count DESC;
94" | dremel --sql_dialect=GoogleSQL --min_completion_ratio=1.0 --output=csv > \
95  "$PAIRWISE_INCLUSIVE_OUTPUT_FILE"
96