Profile simulation performance using Linux perf and visualize the
results with Hotspot. Uses the
profile build mode.
Profiling requires:
- Linux
perftool — theperf recordcommand must be available onPATH. On Debian/Ubuntu, install it withsudo apt install linux-tools-common linux-tools-$(uname -r). perf_event_paranoidsysctl — the kernel must allowperf record. Check withcat /proc/sys/kernel/perf_event_paranoid; a value of1or lower is needed. To lower it temporarily:sudo sysctl kernel.perf_event_paranoid=1.- Hotspot (optional) — required only
by
open_profile_report()to visualize the profile interactively. Without it you can still usegenerate_profile_report()to produce theperf.datafile and analyze it with other tools. - OMNeT++
profilebuild mode — the project is automatically built inprofilemode, which compiles with debug symbols and optimization enabled. See Building for how build modes work.
No extra Python packages are required.
Both generate_profile_report() and open_profile_report() follow the same
pipeline:
- The simulation project is built in
profilemode (optimized with debug symbols). - The simulation is run under
perf record -g --call-graph dwarf, which collects a hardware-level call-graph profile. - The output is written to
perf.data(or a custom name via theoutput_fileparameter) in the simulation's working directory. open_profile_report()additionally launches Hotspot to visualize the profile interactively.
The functions accept all the same filter parameters as run_simulations()
(e.g. working_directory_filter, config_filter, run_number,
sim_time_limit).
# Generate a perf.data profile and open it in Hotspot
open_profile_report(simulation_project=inet_project,
working_directory_filter="examples/ethernet",
config_filter="General",
run_number=0,
sim_time_limit="10s")report_file = generate_profile_report(
simulation_project=inet_project,
working_directory_filter="examples/ethernet",
config_filter="General",
run_number=0,
sim_time_limit="10s")
# report_file is a project-relative path, e.g. "examples/ethernet/lans/perf.data"The returned path can be analyzed with any perf-compatible tool:
perf report -i examples/ethernet/lans/perf.dataBoth functions accept:
simulation_project— the simulation project (defaults to the current default project)output_file— file name for theperf.dataoutput (default"perf.data")- All filter parameters from
run_simulations():working_directory_filter,config_filter,run_number,sim_time_limit, etc.
There are no dedicated command-line wrappers for profiling. Use the Python
API from within opp_repl.