Skip to content

Commit 1370d81

Browse files
chen-harrisonmergify[bot]
authored andcommitted
First Draft of Changes to Profiler Tutorial (#711)
- Explicitly create new project directory called profiler_example - Download profiler.cc into directory using wget - Remove unnecessary grep dependency - Clarify the CMakeLists is being created, not modified - Separate the different options for running the profiler visualization into multiple blocks, with the conditions described more clearly - Would like confirmation on what IP address http.server broadcasts to; tutorial says it's the container's IP address, but it always showed up as 0.0.0.0 (localhost) for me in my container Signed-off-by: Harrison Chen <[email protected]> Co-authored-by: Addisu Z. Taddese <[email protected]> (cherry picked from commit 2b33445) # Conflicts: # tutorials/profiler.md
1 parent 2e575b8 commit 1370d81

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

tutorials/profiler.md

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,21 @@ In order to use the profiler, inspection points must be added to the source code
2525
and the application or library must be linked to the `gz-common::profiler`
2626
component.
2727

28+
<<<<<<< HEAD
2829
To start, download the [profiler.cc](https://github.com/gazebosim/gz-common/raw/main/examples/profiler.cc) example.
30+
=======
31+
To start, create a new CMake project directory and navigate to it:
32+
33+
```{.sh}
34+
mkdir -p ~/profiler_example && cd ~/profiler_example
35+
```
36+
37+
Next, download the [profiler.cc](https://github.com/gazebosim/gz-common/raw/gz-common7/examples/profiler.cc) example into the project:
38+
39+
```{.sh}
40+
wget https://raw.githubusercontent.com/gazebosim/gz-common/gz-common7/examples/profiler.cc
41+
```
42+
>>>>>>> 2b33445 (First Draft of Changes to Profiler Tutorial (#711))
2943
3044
The relevant corresponding C++ would be as follows:
3145

@@ -53,7 +67,7 @@ void thread(const char *_thread_name)
5367
}
5468
```
5569

56-
Update your CMakeLists.txt to the following. Note that the profiler must be
70+
Create a new `CMakeLists.txt` at the root of the project directory (`~/profiler_example`). Note that the profiler must be
5771
enabled at compile time in order to function.
5872

5973
```{.cpp}
@@ -71,46 +85,58 @@ target_compile_definitions(profiler_example PUBLIC "GZ_PROFILER_ENABLE=1")
7185
Run `cmake` and build the example
7286

7387
```{.sh}
74-
cd build
88+
mkdir -p build && cd build
7589
cmake ..
7690
make profiler_example
7791
```
7892

79-
Then execute the example and the profiler visualization:
93+
Then use two terminals to execute the example and the profiler visualization:
8094

81-
From terminal 1:
95+
From terminal 1, inside `~/profiler_example/build`:
8296

8397
```{.sh}
8498
./profiler_example
8599
```
86100

87-
From terminal 2, open the visualizer using one of the following commands
101+
From terminal 2, use one of the following commands, depending on your configuration:
88102

89-
```{.sh}
90-
# Find the launcher script and use it (Linux and macOS)
91-
find /usr | grep gz_remotery_vis
92-
...
103+
- If you installed `gz-common` as a package/binary:
104+
- Open the HTML file directly via a convenience script:
93105

94-
/usr/<path_to>/gz_remotery_vis
106+
```{.sh}
107+
$(find /usr -type f -name 'gz_remotery_vis')
108+
```
95109

96-
# Use the source path (Linux)
97-
# Substitute the path to your gz-common source checkout
98-
xdg-open $SOURCE_DIR/gz-common/profiler/src/Remotery/vis/index.html
110+
- Or, if you're running inside a Docker container, start a server:
99111

112+
<<<<<<< HEAD
100113
# Use the installation path (Linux)
101114
# This may vary depending on where you have choosen to install
102115
xdg-open /usr/share/gz/gz-common6/profiler_vis/index.html
103116

104117
# Use the installation path (macOS)
105118
open /usr/share/gz/gz-common6/profiler_vis/index.html
119+
=======
120+
```{.sh}
121+
python3 -m http.server -d $(find / -type d -name 'profiler_vis')
122+
```
106123

107-
# Inside a Docker container with port 8000 exposed
108-
# 1. Find your container's IP with 'ifconfig'
109-
# 2. Start a basic web server:
110-
python3 -m http.server $SOURCE_DIR/gz-common/profiler/src/Remotery/vis/index.html
111-
# 3. Open URL "http://<container IP>:8000/" with a browser on the host.
112-
```
124+
- If you installed `gz-common` from source, we assume it is located at `$SOURCE_DIR/gz-common`, where `$SOURCE_DIR` is a variable representing a file path
125+
- Open the HTML file directly:
126+
>>>>>>> 2b33445 (First Draft of Changes to Profiler Tutorial (#711))
127+
128+
```{.sh}
129+
xdg-open $SOURCE_DIR/gz-common/profiler/src/Remotery/vis/index.html
130+
```
131+
132+
- Or, if you're running inside a Docker container, start a server:
133+
134+
```{.sh}
135+
python3 -m http.server -d $SOURCE_DIR/gz-common/profiler/src/Remotery/vis
136+
```
113137

138+
If you are running the profiler visualization as a server, the command will display an output `Serving HTTP on [IP_ADDRESS]
139+
port 8000 (http://[IP_ADDRESS]:8000/) ...` - navigate to that URL in your browser and you should see the profiler displayed.
114140
### On Gazebo library
115141

116142
If you want to use profiler on any other Gazebo library, enable the profiler at compile time with ``ENABLE_PROFILER`` cmake argument.

0 commit comments

Comments
 (0)