1#RUN: llvm-xray stack -per-thread-stacks %s | FileCheck %s --check-prefix PER-THREAD
2#RUN: llvm-xray stack -aggregate-threads %s | FileCheck %s --check-prefix AGGREGATE
3
4---
5header:
6  version: 1
7  type: 0
8  constant-tsc: true
9  nonstop-tsc: true
10  cycle-frequency: 2601000000
11records:
12  - { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, tsc: 10001 }
13  - { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, tsc: 10100 }
14  - { type: 1, func-id: 1, cpu: 1, thread: 111, kind: function-exit, tsc: 10101 }
15  - { type: 1, func-id: 1, cpu: 1, thread: 111, kind: function-exit, tsc: 10301 }
16  - { type: 0, func-id: 1, cpu: 1, thread: 111, kind: function-enter, tsc: 10401 }
17  - { type: 0, func-id: 2, cpu: 1, thread: 111, kind: function-enter, tsc: 10501 }
18  - { type: 0, func-id: 3, cpu: 1, thread: 111, kind: function-enter, tsc: 10601 }
19  - { type: 1, func-id: 3, cpu: 1, thread: 111, kind: function-exit, tsc: 10701 }
20  - { type: 1, func-id: 2, cpu: 1, thread: 111, kind: function-exit, tsc: 10751 }
21  - { type: 1, func-id: 1, cpu: 1, thread: 111, kind: function-exit, tsc: 10775 }
22  - { type: 0, func-id: 1, cpu: 1, thread: 123, kind: function-enter, tsc: 10401 }
23  - { type: 0, func-id: 2, cpu: 1, thread: 123, kind: function-enter, tsc: 10501 }
24  - { type: 0, func-id: 3, cpu: 1, thread: 123, kind: function-enter, tsc: 10701 }
25  - { type: 1, func-id: 3, cpu: 1, thread: 123, kind: function-exit, tsc: 10801 }
26  - { type: 1, func-id: 2, cpu: 1, thread: 123, kind: function-exit, tsc: 10951 }
27  - { type: 1, func-id: 1, cpu: 1, thread: 123, kind: function-exit, tsc: 11075 }
28  - { type: 0, func-id: 2, cpu: 1, thread: 200, kind: function-enter, tsc: 0 }
29  - { type: 0, func-id: 3, cpu: 1, thread: 200, kind: function-enter, tsc: 10 }
30  - { type: 1, func-id: 3, cpu: 1, thread: 200, kind: function-exit, tsc: 20 }
31  - { type: 1, func-id: 2, cpu: 1, thread: 200, kind: function-exit, tsc: 30 }
32...
33# PER-THREAD: Thread 123
34# PER-THREAD: Unique Stacks: 1
35# PER-THREAD: Top 10 Stacks by leaf sum:
36# PER-THREAD: Sum: 100
37# PER-THREAD: lvl   function{{[[:space:]]+}}count{{[[:space:]]+}}sum
38# PER-THREAD: #0    #1{{[[:space:]]+}}1{{[[:space:]]+}}674
39# PER-THREAD: #1    #2{{[[:space:]]+}}1{{[[:space:]]+}}450
40# PER-THREAD: #2    #3{{[[:space:]]+}}1{{[[:space:]]+}}100
41# PER-THREAD: Top 10 Stacks by leaf count:
42# PER-THREAD: #0    #1{{[[:space:]]+}}1{{[[:space:]]+}}674
43# PER-THREAD: #1    #2{{[[:space:]]+}}1{{[[:space:]]+}}450
44# PER-THREAD: #2    #3{{[[:space:]]+}}1{{[[:space:]]+}}100
45# PER-THREAD: lvl   function{{[[:space:]]+}}count{{[[:space:]]+}}sum
46
47# AGGREGATE: Unique Stacks: 3
48# AGGREGATE: Top 10 Stacks by leaf sum:
49# AGGREGATE: Sum: 200
50
51# AGGREGATE: lvl   function{{[[:space:]]+}}count{{[[:space:]]+}}sum
52# AGGREGATE: #0    #1{{[[:space:]]+}}3{{[[:space:]]+}}1348
53# AGGREGATE: #1    #2{{[[:space:]]+}}2{{[[:space:]]+}}700
54# AGGREGATE: #2    #3{{[[:space:]]+}}2{{[[:space:]]+}}200
55
56# AGGREGATE: Sum: 10
57# AGGREGATE: lvl   function{{[[:space:]]+}}count{{[[:space:]]+}}sum
58# AGGREGATE: #0    #2{{[[:space:]]+}}1{{[[:space:]]+}}30
59# AGGREGATE: #1    #3{{[[:space:]]+}}1{{[[:space:]]+}}10
60
61# AGGREGATE: Sum: 1
62# AGGREGATE: lvl   function{{[[:space:]]+}}count{{[[:space:]]+}}sum
63# AGGREGATE: #0    #1{{[[:space:]]+}}2{{[[:space:]]+}}674
64# AGGREGATE: #1    #1{{[[:space:]]+}}1{{[[:space:]]+}}1
65
66
67# AGGREGATE: Top 10 Stacks by leaf count:
68
69# AGGREGATE: Count: 2
70# AGGREGATE: lvl   function{{[[:space:]]+}}count{{[[:space:]]+}}sum
71# AGGREGATE: #0    #1{{[[:space:]]+}}3{{[[:space:]]+}}1348
72# AGGREGATE: #1    #2{{[[:space:]]+}}2{{[[:space:]]+}}700
73# AGGREGATE: #2    #3{{[[:space:]]+}}2{{[[:space:]]+}}200
74
75# AGGREGATE: Count: 1
76# AGGREGATE: lvl   function{{[[:space:]]+}}count{{[[:space:]]+}}sum
77# AGGREGATE: #0    #2{{[[:space:]]+}}1{{[[:space:]]+}}30
78# AGGREGATE: #1    #3{{[[:space:]]+}}1{{[[:space:]]+}}10
79
80# AGGREGATE: Count: 1
81# AGGREGATE: lvl   function{{[[:space:]]+}}count{{[[:space:]]+}}sum
82# AGGREGATE: #0    #1{{[[:space:]]+}}2{{[[:space:]]+}}674
83# AGGREGATE: #1    #1{{[[:space:]]+}}1{{[[:space:]]+}}1
84