Rust bindings for Amazon's Hawktracer profiler.
This offers simple, minimal bindings to help you profile your programs.
You need an external tool in order to transform bindings from a binary format to something that can be interpreted by chrome:://tracing
This tool can be build for now from the main hawktracer repo (client/hawktracer-to-json).
I recommend taking the binaries from the official rust_hawktracer releases: https://github.com/amzn/hawktracer/releases/tag/v0.6.0
In Cargo.toml:
toml
[dependencies]
rust_hawktracer = {git = "https://github.com/AlexEne/rust_hawktracer.git", features=["profiling_enabled"]}
In your main.rs:
```rust
extern crate rusthawktracer; use rusthawktracer::*; use std::{thread, time};
fn main() { let instance = createhawktracerinstance("trace.bin", 4096); println!("Hello, world!"); { scopedtracepoint!(test); thread::sleep(time::Duration::frommillis(10));
{
for _ in 0..10 {
scoped_tracepoint!(_second_tracepoint);
thread::sleep(time::Duration::from_millis(10));
}
}
}
} ```
Download hawktracer-converter.exe and use it like this:
.\hawktracer-converter.exe --source trace.bin --output trace.json
Open a chrome browser and go to this address: chrome://tracing/
For the program above you should see the following trace:
In rust macros I can't create new variable names right now, this means that if you want to avoid warnings, the tracepoint variable names have to start with a leading _
, as in scoped_tracepoint!(_second_tracepoint)
.
If you figure out a way to do this, feel free to raise a PR / issue.