radiate_core/stats/
mod.rs1pub mod distribution;
2pub mod histogram;
3pub mod metrics;
4pub mod query;
5pub mod statistics;
6pub mod time_statistic;
7
8pub use distribution::*;
9pub use histogram::*;
10pub use metric_names::*;
11pub use metrics::*;
12pub use query::*;
13pub use statistics::*;
14pub use time_statistic::*;
15
16pub mod metric_names {
17 pub const TIME: &str = "time";
18
19 pub const SCORE_IMPROVEMENT_RATE: &str = "score_improv_rate";
20 pub const SCORES: &str = "scores";
21 pub const AGE: &str = "age";
22
23 pub const REPLACE_AGE: &str = "replace_age";
24 pub const REPLACE_INVALID: &str = "replace_invalid";
25
26 pub const GENOME_SIZE: &str = "genome_size";
27 pub const FRONT: &str = "front";
28
29 pub const UNIQUE_MEMBERS: &str = "unique_members";
30 pub const UNIQUE_SCORES: &str = "unique_scores";
31
32 pub const EVALUATION_COUNT: &str = "evaluation_count";
33
34 pub const DIVERSITY_RATIO: &str = "diversity_ratio";
35 pub const SCORE_VOLATILITY: &str = "score_volatility";
36
37 pub const SPECIES_COUNT: &str = "species_count";
38 pub const SPECIES_AGE_FAIL: &str = "species_age_fail";
39 pub const SPECIES_DISTANCE_DIST: &str = "species_distance_dist";
40 pub const SPECIES_CREATED: &str = "species_created";
41 pub const SPECIES_DIED: &str = "species_died";
42 pub const SPECIES_AGE: &str = "species_age";
43}
44
45pub trait ToSnakeCase {
46 fn to_snake_case(&self) -> String;
47}
48
49impl ToSnakeCase for &'_ str {
50 fn to_snake_case(&self) -> String {
51 let mut snake_case = String::new();
52 for (i, c) in self.chars().enumerate() {
53 if c.is_uppercase() {
54 if i != 0 {
55 snake_case.push('_');
56 }
57 for lower_c in c.to_lowercase() {
58 snake_case.push(lower_c);
59 }
60 } else {
61 snake_case.push(c);
62 }
63 }
64 snake_case
65 }
66}
67
68impl ToSnakeCase for String {
69 fn to_snake_case(&self) -> String {
70 let mut snake_case = String::new();
71 for (i, c) in self.chars().enumerate() {
72 if c.is_uppercase() {
73 if i != 0 {
74 snake_case.push('_');
75 }
76 for lower_c in c.to_lowercase() {
77 snake_case.push(lower_c);
78 }
79 } else {
80 snake_case.push(c);
81 }
82 }
83 snake_case
84 }
85}