Expand description
This crate allows you to create a profile that can be loaded into the Firefox Profiler.
Specifically, this uses the “Processed profile format”.
Use Profile::new
to create a new Profile
object. Then add all the
information into it. To convert it to JSON, use serde_json
, for
example serde_json::to_writer
or serde_json::to_string
.
§Example
use fxprof_processed_profile::{Profile, CategoryHandle, CpuDelta, Frame, FrameInfo, FrameFlags, SamplingInterval, Timestamp};
use std::time::SystemTime;
let mut profile = Profile::new("My app", SystemTime::now().into(), SamplingInterval::from_millis(1));
let process = profile.add_process("App process", 54132, Timestamp::from_millis_since_reference(0.0));
let thread = profile.add_thread(process, 54132000, Timestamp::from_millis_since_reference(0.0), true);
profile.set_thread_name(thread, "Main thread");
let stack_frames = vec![
FrameInfo { frame: Frame::Label(profile.intern_string("Root node")), category_pair: CategoryHandle::OTHER.into(), flags: FrameFlags::empty() },
FrameInfo { frame: Frame::Label(profile.intern_string("First callee")), category_pair: CategoryHandle::OTHER.into(), flags: FrameFlags::empty() }
];
let stack = profile.intern_stack_frames(thread, stack_frames.into_iter());
profile.add_sample(thread, Timestamp::from_millis_since_reference(0.0), stack, CpuDelta::ZERO, 1);
let writer = std::io::BufWriter::new(output_file);
serde_json::to_writer(writer, &profile)?;
Re-exports§
pub use debugid;
Structs§
- Category
Handle - A profiling category, can be set on stack frames and markers as part of a
CategoryPairHandle
. - Category
Pair Handle - A profiling category pair, consisting of a category and an optional subcategory. Can be set on stack frames and markers.
- Counter
Handle - A counter. Can be created with
Profile::add_counter
. - CpuDelta
- The amount of CPU time between thread samples.
- Frame
Flags - Flags for a stack frame.
- Frame
Handle - A handle to a frame, specific to a thread. Can be created with
Profile::intern_frame
. - Frame
Info - All the information about a single stack frame.
- LibMappings
- Keeps track of mapped libraries in an address space. Stores a value for each mapping, and allows efficient lookup of that value based on an address.
- Library
Handle - The handle for a library, obtained from
Profile::add_lib
. - Library
Info - A library (“binary” / “module” / “DSO”) which is loaded into a process. This can be the main executable file or a dynamic library, or any other mapping of executable memory.
- Marker
Field Flags - Marker field flags, used in the marker schema.
- Marker
Handle - The handle for a marker. Returned from
Profile::add_marker
. - Marker
Locations - Locations in the profiler UI where markers can be displayed.
- Marker
Type Handle - The handle for a marker type. Returned from
Profile::register_marker_type
. - Process
Handle - A process. Can be created with
Profile::add_process
. - Profile
- Stores the profile data and can be serialized as JSON, via
serde::Serialize
. - Reference
Timestamp - A timestamp which anchors the profile in absolute time.
- Runtime
Schema Marker Field - The field definition of a marker field, used in
RuntimeSchemaMarkerSchema::fields
. - Runtime
Schema Marker Graph - A graph within a marker graph track, used in
RuntimeSchemaMarkerSchema::graphs
. - Runtime
Schema Marker Schema - Describes a marker type, including the names and types of the marker’s fields.
You only need this if you don’t know the schema until runtime. Otherwise, use
StaticSchemaMarker
instead. - Sampling
Interval - The sampling interval used during profile recording.
- Stack
Handle - A handle to a stack, specific to a thread. Can be created with
Profile::intern_stack
. - Static
Schema Marker Field - The field definition of a marker field, used in
StaticSchemaMarker::FIELDS
. - Static
Schema Marker Graph - A graph within a marker graph track, used in
StaticSchemaMarker::GRAPHS
. - String
Handle - A handle for an interned string, returned from
Profile::intern_string
. - Symbol
- A single symbol from a
SymbolTable
. - Symbol
Table - A symbol table which contains a list of
Symbol
s, used inLibraryInfo
. - Thread
Handle - A thread. Can be created with
Profile::add_thread
. - Timestamp
- The type used for sample and marker timestamps.
- Used
Library Addresses Iterator
Enums§
- Category
Color - One of the available colors for a category.
- Frame
- A part of the information about a single stack frame.
- Graph
Color - The color used for a graph segment within a marker graph.
- Marker
Field Format - The field format of a marker field.
- Marker
Field Format Kind - The kind of a marker field. Every marker field is either a string or a number.
- Marker
Graph Type - The type of a graph segment within a marker graph.
- Marker
Timing - Specifies timestamps for a marker.
- Weight
Type - Specifies the meaning of the “weight” value of a thread’s samples.
Traits§
- Marker
- The marker trait. You’ll likely want to implement
StaticSchemaMarker
instead. - Static
Schema Marker - The trait for markers whose schema is known at compile time. Any type which implements
StaticSchemaMarker
automatically implements theMarker
trait via a blanket impl.