Skip to main content

browser_protocol/performance/
mod.rs

1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3
4/// Run-time execution metric.
5
6#[derive(Debug, Clone, Serialize, Deserialize, Default)]
7#[serde(rename_all = "camelCase")]
8pub struct Metric {
9    /// Metric name.
10
11    pub name: String,
12    /// Metric value.
13
14    pub value: f64,
15}
16
17#[derive(Debug, Clone, Serialize, Deserialize, Default)]
18pub struct DisableParams {}
19
20impl DisableParams { pub const METHOD: &'static str = "Performance.disable"; }
21
22impl crate::CdpCommand for DisableParams {
23    const METHOD: &'static str = "Performance.disable";
24    type Response = crate::EmptyReturns;
25}
26
27/// Enable collecting and reporting metrics.
28
29#[derive(Debug, Clone, Serialize, Deserialize, Default)]
30#[serde(rename_all = "camelCase")]
31pub struct EnableParams {
32    /// Time domain to use for collecting and reporting duration metrics.
33
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub timeDomain: Option<String>,
36}
37
38impl EnableParams { pub const METHOD: &'static str = "Performance.enable"; }
39
40impl crate::CdpCommand for EnableParams {
41    const METHOD: &'static str = "Performance.enable";
42    type Response = crate::EmptyReturns;
43}
44
45/// Sets time domain to use for collecting and reporting duration metrics.
46/// Note that this must be called before enabling metrics collection. Calling
47/// this method while metrics collection is enabled returns an error.
48
49#[derive(Debug, Clone, Serialize, Deserialize, Default)]
50#[serde(rename_all = "camelCase")]
51pub struct SetTimeDomainParams {
52    /// Time domain
53
54    pub timeDomain: String,
55}
56
57impl SetTimeDomainParams { pub const METHOD: &'static str = "Performance.setTimeDomain"; }
58
59impl crate::CdpCommand for SetTimeDomainParams {
60    const METHOD: &'static str = "Performance.setTimeDomain";
61    type Response = crate::EmptyReturns;
62}
63
64/// Retrieve current values of run-time metrics.
65
66#[derive(Debug, Clone, Serialize, Deserialize, Default)]
67#[serde(rename_all = "camelCase")]
68pub struct GetMetricsReturns {
69    /// Current values for run-time metrics.
70
71    pub metrics: Vec<Metric>,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize, Default)]
75pub struct GetMetricsParams {}
76
77impl GetMetricsParams { pub const METHOD: &'static str = "Performance.getMetrics"; }
78
79impl crate::CdpCommand for GetMetricsParams {
80    const METHOD: &'static str = "Performance.getMetrics";
81    type Response = GetMetricsReturns;
82}