Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some docs #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,32 @@ Read more about the usage and associated tools at https://aras-p.info/blog/2017/

## Hookup

Call `register_thread_with_profiler` for each thread.

Call `write_profile` when you need to save the results.
Call `register_thread_with_profiler()` for each thread.

Call `profile_scope!("what you are measuring")` for each scope to profile. Will introduce a hidden variable that stops the profiling of the section when going out of scope.

Call `write_profile(file_path)` when you need to save the results. Make sure all profiles introduced with `profile_scope!` are actually out of scope.

## Example

```rust
thread::spawn(|| {
register_thread_with_profiler();

{
profile_scope!(format!("Thread {:?}, section {:?}", 1, "init"));
// your "init" stuff goes here
} // profiling scope ends here

{
profile_scope!(...);
// and so on
}
});

// at the very end, after joining all threads
write_profile("/some/place/for/your/profile.json");
```

## View results

Expand Down