solomon_gremlin/structure/
metrics.rs1#[derive(Debug, PartialEq, Eq, Clone)]
2pub struct TraversalExplanation {
3 final_t: Vec<String>,
4 original: Vec<String>,
5 intermediate: Vec<IntermediateRepr>,
6}
7
8impl TraversalExplanation {
9 pub fn final_t(&self) -> &Vec<String> {
10 &self.final_t
11 }
12 pub fn original(&self) -> &Vec<String> {
13 &self.original
14 }
15
16 pub fn intermediate(&self) -> &Vec<IntermediateRepr> {
17 &self.intermediate
18 }
19}
20#[derive(Debug, PartialEq, Eq, Clone)]
21pub struct IntermediateRepr {
22 traversal: Vec<String>,
23 strategy: String,
24 category: String,
25}
26
27impl IntermediateRepr {
28 pub fn new(traversal: Vec<String>, strategy: String, category: String) -> IntermediateRepr {
29 IntermediateRepr {
30 traversal,
31 strategy,
32 category,
33 }
34 }
35}
36impl TraversalExplanation {
37 pub fn new(
38 original: Vec<String>,
39 final_t: Vec<String>,
40 intermediate: Vec<IntermediateRepr>,
41 ) -> TraversalExplanation {
42 TraversalExplanation {
43 final_t,
44 original,
45 intermediate,
46 }
47 }
48}
49
50#[derive(Debug, PartialEq, Clone)]
51pub struct TraversalMetrics {
52 duration: f64,
53 metrics: Vec<Metric>,
54}
55
56impl TraversalMetrics {
57 pub fn duration(&self) -> &f64 {
58 &self.duration
59 }
60
61 pub fn metrics(&self) -> &Vec<Metric> {
62 &self.metrics
63 }
64}
65
66impl TraversalMetrics {
67 pub fn new(duration: f64, metrics: Vec<Metric>) -> Self {
68 TraversalMetrics {
69 duration,
70 metrics,
71 }
72 }
73}
74
75#[derive(Debug, PartialEq, Clone)]
76pub struct Metric {
77 id: String,
78 duration: f64,
79 name: String,
80 count: i64,
81 traversers: i64,
82 perc_duration: f64,
83 nested: Vec<Metric>,
84}
85
86impl Metric {
87 pub fn id(&self) -> &String {
88 &self.id
89 }
90 pub fn name(&self) -> &String {
91 &self.name
92 }
93 pub fn duration(&self) -> &f64 {
94 &self.duration
95 }
96
97 pub fn perc_duration(&self) -> &f64 {
98 &self.perc_duration
99 }
100 pub fn count(&self) -> &i64 {
101 &self.count
102 }
103 pub fn traversers(&self) -> &i64 {
104 &self.traversers
105 }
106}
107
108impl Metric {
109 pub fn new<T, V>(
110 id: T,
111 name: V,
112 duration: f64,
113 count: i64,
114 traversers: i64,
115 perc_duration: f64,
116 nested: Vec<Metric>,
117 ) -> Self
118 where
119 T: Into<String>,
120 V: Into<String>,
121 {
122 Metric {
123 id: id.into(),
124 name: name.into(),
125 duration,
126 count,
127 traversers,
128 perc_duration,
129 nested,
130 }
131 }
132}