Name Date Size #Lines LOC

..--

src/H25-Apr-2025-580508

Cargo.lockH A D25-Apr-202513.2 KiB509448

Cargo.tomlH A D25-Apr-2025353 1814

README.mdH A D25-Apr-20252.2 KiB9973

flamegraph.htmlH A D25-Apr-2025841 2721

histogram.pyH A D25-Apr-2025575 2114

README.md

1# Analyzes cros_tracing event
2
3Extract event_data and timestamp from input file from `trace-cmd record` and calculate average
4latency of cros_tracing events
5
6## How to list cros_tracing event name
7
8```
9$ cargo run -- list --input trace.dat --count 10
10```
11
12Print list of function names and sum of latency in the trace.dat. Example log:
13
14```
15#1: read: 728685132 usec
16#2: readdir: 719231760 usec
17#3: lookup: 460496754 usec
18#4: open: 38860424 usec
19#5: opendir: 38159576 usec
20#6: getxattr: 21408816 usec
21#7: release: 17821045 usec
22#8: releasedir: 17783896 usec
23#9: forget: 2942940 usec
24#10: getattr: 301824 usec
25```
26
27## How to generate histogram
28
29```
30$ cargo run -- histogram --input trace.dat --output histogram.json
31```
32
33To run the python script that generates the histogram plots, you need to install the `matplotlib`
34python library.
35
36```
37$ sudo apt-get install python3-matplotlib
38```
39
40To visualize the histogram,
41
42```
43$ python3 histogram.py ./src/histogram.json
44```
45
46And then histograms for each cros_tracing event will be displayed.
47
48## How to calculate event average latency
49
50```
51$ cargo run -- average --input trace.dat
52```
53
54calculate the average latency for each virtiofs event and print. Example log:
55
56```
57#0: readdir: 307364 usec
58#1: read: 303366 usec
59#2: lookup: 71762 usec
60#3: open: 34148 usec
61#4: opendir: 34132 usec
62#5: statfs: 27116 usec
63#6: forget: 26754 usec
64#7: getxattr: 18714 usec
65#8: getattr: 16768 usec
66#9: release: 15983 usec
67#10: releasedir: 15964 usec
68#11: readlink: 15480 usec
69#12: flush: 11939 usec
70```
71
72## How to generate flamegraph data
73
74```
75$ cargo run -- flamegraph --input trace.dat --output-json tracing_data.json
76```
77
78Extract all events and calculate its latency and output it to a json file compatibile with d3
79flamegraph.
80
81To visualize the html page with the flamegraph, you need to run a local webserver. You can do this
82with a simple python http server:
83
84```
85$ python3 -m http.server
86```
87
88And then open the page at http://localhost:8000/flamegraph.html and the flamegraph will be
89displayed.
90
91### How to apply filters to the flamegraph
92
93```
94$ cargo run -- flamegraph --input trace.dat --output-json tracing_data.json --function "lookup" --count 20
95```
96
97For example this command outputs the data of the top 20 "lookup" functions that are taking the most
98time:
99