Name Description Size
deserializer_tags_state.rs 4964
mod.rs ## Gecko profiler marker support This marker API has a few different functions that you can use to mark a part of your code. There are three main marker functions to use from Rust: [`add_untyped_marker`], [`add_text_marker`] and [`add_marker`]. They are similar to what we have on the C++ side. Please take a look at the marker documentation in the Firefox source docs to learn more about them: https://firefox-source-docs.mozilla.org/tools/profiler/markers-guide.html ### Simple marker without any additional data The simplest way to add a marker without any additional information is the [`add_untyped_marker`] API. You can use it to mark a part of the code with only a name. E.g.: ``` gecko_profiler::add_untyped_marker( // Name of the marker as a string. "Marker Name", // Category with an optional sub-category. gecko_profiler_category!(Graphics, DisplayListBuilding), // MarkerOptions that keeps options like marker timing and marker stack. Default::default(), ); ``` Please see the [`gecko_profiler_category!`], [`MarkerOptions`],[`MarkerTiming`] and [`MarkerStack`] to learn more about these. You can also give explicit [`MarkerOptions`] value like these: ``` // With both timing and stack fields: MarkerOptions { timing: MarkerTiming::instant_now(), stack: MarkerStack::Full } // Or with some fields as default: MarkerOptions { timing: MarkerTiming::instant_now(), ..Default::default() } ``` ### Marker with only an additional text for more information: The next and slightly more advanced API is [`add_text_marker`]. This is used to add a marker name + a string value for extra information. E.g.: ``` let info = "info about this marker"; ... gecko_profiler::add_text_marker( // Name of the marker as a string. "Marker Name", // Category with an optional sub-category. gecko_profiler_category!(DOM), // MarkerOptions that keeps options like marker timing and marker stack. MarkerOptions { timing: MarkerTiming::instant_now(), ..Default::default() }, // Additional information as a string. info, ); ``` ### Marker with a more complex payload and different visualization in the profiler front-end. [`add_marker`] is the most advanced API that you can use to add different types of values as data to your marker and customize the visualization of that marker in the profiler front-end (profiler.firefox.com). To be able to add a a marker, first you need to create your marker payload struct in your codebase and implement the [`ProfilerMarker`] trait like this: ``` #[derive(Serialize, Deserialize, Debug)] pub struct TestMarker { a: u32, b: String, } // Please see the documentation of [`ProfilerMarker`]. impl gecko_profiler::ProfilerMarker for TestMarker { fn marker_type_name() -> &'static str { "marker type from rust" } fn marker_type_display() -> gecko_profiler::MarkerSchema { use gecko_profiler::marker::schema::*; let mut schema = MarkerSchema::new(&[Location::MarkerChart]); schema.set_chart_label("Name: {marker.name}"); schema.set_tooltip_label("{marker.data.a}"); schema.add_key_label_format("a", "A Value", Format::Integer); schema.add_key_label_format("b", "B Value", Format::String); schema } fn stream_json_marker_data(&self, json_writer: &mut gecko_profiler::JSONWriter) { json_writer.int_property("a", self.a.into()); json_writer.string_property("b", &self.b); } } ``` Once you've created this payload and implemented the [`ProfilerMarker`], you can now add this marker in the code that you would like to measure. E.g.: ``` gecko_profiler::add_marker( // Name of the marker as a string. "Marker Name", // Category with an optional sub-category. gecko_profiler_category!(Graphics, DisplayListBuilding), // MarkerOptions that keeps options like marker timing and marker stack. Default::default(), // Marker payload. TestMarker {a: 12, b: "hello".to_owned()}, ); ``` 10525
options.rs Different options for the marker API. See [`MarkerOptions`] and its fields. 4858
schema.rs [`MarkerSchema`] and other enums that will be used by `MarkerSchema`. 9086