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

Add some docs #17

wants to merge 1 commit into from

Conversation

felixrabe
Copy link

Took a few funny looks at 2-byte [] profiles to figure this out 😅

Took a few funny looks at 2-byte `[]` profiles to figure this out 😅
@azriel91
Copy link

azriel91 commented Dec 13, 2019

@felixrabe Hiya, thank you for opening this, but for some reason I still can't get it to work:

fn main() {
    thread_profiler::register_thread_with_profiler();

    // Attempt 1: main thread:
    {
        thread_profiler::profile_scope!("Sleepy");
        std::thread::sleep(std::time::Duration::from_millis(200));
    }

    // Attempt 2: sub thread:
    let thread_handle = std::thread::spawn(|| {
        thread_profiler::register_thread_with_profiler();
        // scope
        {
            thread_profiler::profile_scope!("Sub sleepy");
            std::thread::sleep(std::time::Duration::from_millis(200));
        }
    });
    thread_handle.join().expect("Failed to join thread");

    thread_profiler::write_profile("profile.json");
}
$ cargo run && cat profile.json
Compiling abc v0.1.0 (/tmp/abc)
    Finished dev [unoptimized + debuginfo] target(s) in 0.27s
     Running `target/debug/abc`
[]

@azriel91
Copy link

Figured it out, thread_profiler 0.3 does not work unless it is declared as an optional dependency:

[dependencies]
thread_profiler = { version = "0.3", optional = true }

[features]
default = ["thread_profiler"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants