Skip to content

Commit c897eb3

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 6dba329 commit c897eb3

File tree

1 file changed

+51
-5
lines changed

1 file changed

+51
-5
lines changed

tutorials/profiler.md

Lines changed: 51 additions & 5 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 `ignition-common::profiler`
2626
component.
2727

28+
<<<<<<< HEAD
2829
To start, download the [profiler.cc](https://github.com/ignitionrobotics/ign-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,21 +85,22 @@ target_compile_definitions(profiler_example PUBLIC "IGN_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

103+
<<<<<<< HEAD
89104
```{.sh}
90105
# Find the launcher script and use it (Linux and macOS)
91106
find /usr | grep ign_remotery_vis
@@ -112,6 +127,37 @@ python3 -m http.server $SOURCE_DIR/ign-common/profiler/src/Remotery/vis/index.ht
112127
```
113128

114129
### On Ignition library
130+
=======
131+
- If you installed `gz-common` as a package/binary:
132+
- Open the HTML file directly via a convenience script:
133+
134+
```{.sh}
135+
$(find /usr -type f -name 'gz_remotery_vis')
136+
```
137+
138+
- Or, if you're running inside a Docker container, start a server:
139+
140+
```{.sh}
141+
python3 -m http.server -d $(find / -type d -name 'profiler_vis')
142+
```
143+
144+
- 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
145+
- Open the HTML file directly:
146+
147+
```{.sh}
148+
xdg-open $SOURCE_DIR/gz-common/profiler/src/Remotery/vis/index.html
149+
```
150+
151+
- Or, if you're running inside a Docker container, start a server:
152+
153+
```{.sh}
154+
python3 -m http.server -d $SOURCE_DIR/gz-common/profiler/src/Remotery/vis
155+
```
156+
157+
If you are running the profiler visualization as a server, the command will display an output `Serving HTTP on [IP_ADDRESS]
158+
port 8000 (http://[IP_ADDRESS]:8000/) ...` - navigate to that URL in your browser and you should see the profiler displayed.
159+
### On Gazebo library
160+
>>>>>>> 2b33445 (First Draft of Changes to Profiler Tutorial (#711))
115161
116162
If you want to use profiler on any other ignition library, enable the profiler at compile time with ``ENABLE_PROFILER`` cmake argument.
117163

0 commit comments

Comments
 (0)