Skip to main content

set_trace_enabled

Function set_trace_enabled 

Source
pub fn set_trace_enabled(enabled: bool) -> bool
Expand description

Turns trace collection on or off, and returns true if the setting changed.

While tracing is off, task polls and frame events update only the cheap statistics, and nothing is added to the trace buffers. Turning tracing off clears the per-thread task buffers and the frame-event buffer, unless a trace scope is still active, so a later re-enable doesn’t report stale data. Active trace scopes keep collection on until the last scope ends, whatever this setting is. Passing the current setting changes nothing and returns false.

§Examples

use gpui::profiler::{set_trace_enabled, trace_enabled};

assert!(set_trace_enabled(true));
assert!(trace_enabled());
assert!(!set_trace_enabled(true), "already on, so nothing changed");
set_trace_enabled(false);