-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
Currently, PID and TID are hardcoded to show only the constant "1":
fn write_results_recursive(file: &mut File, result: &GpuTimerScopeResult, last: bool) -> std::io::Result<()> {
write!(
file,
r#"{{ "pid":1, "tid":1, "ts":{}, "dur":{}, "ph":"X", "name":"{}" }}{}"#,
result.time.start * 1000.0 * 1000.0,
(result.time.end - result.time.start) * 1000.0 * 1000.0,
result.label,
if last && result.nested_scopes.is_empty() { "\n" } else { ",\n" }
)?;
if result.nested_scopes.is_empty() {
return Ok(());
}
for child in result.nested_scopes.iter().take(result.nested_scopes.len() - 1) {
write_results_recursive(file, child, false)?;
}
write_results_recursive(file, result.nested_scopes.last().unwrap(), last)?;
Ok(())
// { "pid":1, "tid":1, "ts":546867, "dur":121564, "ph":"X", "name":"DoThings"
}
They should be changed to output the proper process and thread id.
Suggestion: use std::process::id()
for the PID and std::thread::current().id()
for the TID. The only problem is that the ThreadId
type in the standard library cannot be trivially converted to a primitive type (int/uint/usize), without using any hacks. Also, ThreadIds
are under the control of Rust’s standard library and there may not be any relationship between ThreadId
and the underlying platform’s notion of a thread identifier (see the official docs). There's a proposal for stabilizing a u64 conversion, though (see this tracking issue)
Metadata
Metadata
Assignees
Labels
No labels