1-- Collects the function, with its file, the object and inclusive count value.
2-- The limits here are entirely arbitrary.
3-- For more background, look at
4-- https://sites.google.com/a/google.com/cwp/about/callgraphs.
5SELECT
6  frame.function_name AS function,
7  frame.filename AS file,
8  frame.load_module_path AS dso,
9  sum(frame.inclusive_count) AS inclusive_count
10FROM
11  -- Collect the data stored in CWP over the last 30 days.
12  FLATTEN(chromeos_wide_profiling.sampledb.cycles.callgraph.last30days, frame)
13WHERE
14  meta.cros.report_id % UINT64("1") == 0
15  -- The reports were collected periodically.
16  AND meta.cros.collection_info.trigger_event == 1
17  AND `profile.duration_usec` < 2100000
18  -- The reports were from a busy machine.
19  AND session.total_count > 2000
20  --  The reports are from the gnawty board, x86_64 architecture.
21  AND meta.cros.board == "gnawty"
22  AND meta.cros.cpu_architecture == "x86_64"
23  -- The reports include callchain data.
24  AND left(meta.cros.version, 4) > "6970"
25  GROUP BY function, dso, file
26ORDER BY `inclusive_count` DESC
27LIMIT 50000 ;
28