rust_hawktracer
Rust bindings for the Hawktracer profiler.
This crate offers simple, minimal bindings to help you profile your rust programs.
If profiling is not enabled by specifying features=["profiling_enabled"]
, having tracepoints in your code has absolutely no overhead (everything gets removed at compile time).
Tools needed
You need an external tool in order to transform captured profiling data from a binary format to something that can be interpreted by chrome:://tracing (or other clients).
I recommend downloading the binaries from the official hawktracer release.
For platforms that don't have a binary release you can build it from the main hawktracer repo.
Profiling code
In Cargo.toml:
[]
= "0.4.0"
=["profiling_enabled"]
If the bindings that come with it don't match what your platform expects change it to:
=["profiling_enabled", "generate_bindings"]
In your main.rs:
extern crate rust_hawktracer;
use *;
use ;
Visualization
If you use HawktracerListenerType::ToFile
:
.\hawktracer-converter.exe --source trace.bin --output trace.json
If you use HawktracerListenerType::TCP
you can listen and capture traces by specifying the IP:port as the --source
parameter:
.\hawktracer-converter.exe --source 127.0.0.1:12345 --output trace.json
Open a chrome browser and go to this address: chrome://tracing/
By opening the trace.json
for the program above you should see something like:
Things to watch out for
In rust macros I can't create new identifier names. This means that if you want to avoid warnings, the tracepoint names have to start with a leading _
, as in scoped_tracepoint!(_my_tracepoint_name)
.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE or http://opensource.org/licenses/MIT)
at your option.