pub struct Bytestat { /* private fields */ }
Implementations§
Source§impl Bytestat
impl Bytestat
Sourcepub fn new() -> Bytestat
pub fn new() -> Bytestat
Examples found in repository?
14fn main() {
15
16 let mut stats = Bytestat::new();
17 let mut counter:u128 = 0;
18 let percent = 256 * 4096;
19
20 for x in std::io::stdin().bytes() {
21 match x {
22 Ok(data) => {
23 stats.analyze(data);
24 counter += 1;
25 },
26 Err(err) => {
27 eprintln!("{:?}", err);
28 }
29 }
30 }
31
32 println!("\nRAW SCORES AS STRING");
33 println!("{}", stats.get_scores_string("\n"));
34
35 println!("\nFINAL SCORE");
36 println!("{} samples", counter );
37 println!("{}{:.0}%", if counter < (percent * 100) {"~"} else {""}, stats.get_score() );
38
39}
Sourcepub fn analyze(&mut self, value: u8)
pub fn analyze(&mut self, value: u8)
Analyze one byte, bytes must be analysed in sequence. If bytes are not analyzed in sequence, the final score will not be valid. Repeat as needed.
§Arguments
value
- A byte to be analyzed, u8
§Examples
use bytestat::Bytestat;
let stats = Bytestat::new();
for x in 0..limit {
let my_byte = get_random_byte();
stats.analyze( my_byte );
}
Examples found in repository?
14fn main() {
15
16 let mut stats = Bytestat::new();
17 let mut counter:u128 = 0;
18 let percent = 256 * 4096;
19
20 for x in std::io::stdin().bytes() {
21 match x {
22 Ok(data) => {
23 stats.analyze(data);
24 counter += 1;
25 },
26 Err(err) => {
27 eprintln!("{:?}", err);
28 }
29 }
30 }
31
32 println!("\nRAW SCORES AS STRING");
33 println!("{}", stats.get_scores_string("\n"));
34
35 println!("\nFINAL SCORE");
36 println!("{} samples", counter );
37 println!("{}{:.0}%", if counter < (percent * 100) {"~"} else {""}, stats.get_score() );
38
39}
Sourcepub fn get_score_non_zero(&mut self) -> f64
pub fn get_score_non_zero(&mut self) -> f64
Generate the score based on distribution of unique bytes being present in the set.
(unique byte present in set) / (maximum number of possible unique bytes, 256)
§Examples
use bytestat::Bytestat;
let stats = Bytestat::new();
for x in 0..limit {
let my_byte = get_random_byte();
stats.analyze( my_byte );
}
stats.get_score_non_zero()
Sourcepub fn get_score_unique(&mut self) -> f64
pub fn get_score_unique(&mut self) -> f64
Generate the score based on the uniqueness of the bytes distribution in the set. The score is between 0.0 and 1.0. Any score lower than 0.99 should be considered problematic.
(unique byte count in set) / (maximum number of possible unique bytes, 256)
§Examples
use bytestat::Bytestat;
let stats = Bytestat::new();
for x in 0..limit {
let my_byte = get_random_byte();
stats.analyze( my_byte );
}
stats.get_score_unique()
Sourcepub fn get_score_amplitude(&mut self) -> f64
pub fn get_score_amplitude(&mut self) -> f64
Generate the score based on the amplitude of the bytes distribution in the set. The score is between 0.0 and 1.0. Any score lower than 0.99 should be considered problematic.
((bytes count max) - (bytes count min)) / (bytes count max)
§Examples
use bytestat::Bytestat;
let stats = Bytestat::new();
for x in 0..limit {
let my_byte = get_random_byte();
stats.analyze( my_byte );
}
stats.get_score_amplitude()
Sourcepub fn get_score_interval_continuity(&mut self) -> f64
pub fn get_score_interval_continuity(&mut self) -> f64
Generate the sub score based on the amplitude of the continuity of significant interval measurements. The score is between 0 and 1. Any score lower than 0.99 should be considered problematic.
( 1 … interval_largest [] ) / (interval_largest)
§Examples
use bytestat::Bytestat;
let stats = Bytestat::new();
for x in 0..limit {
let my_byte = get_random_byte();
stats.analyze( my_byte );
}
stats.get_score_amplitude()
Sourcepub fn get_score_interval_amplitude(&mut self) -> f64
pub fn get_score_interval_amplitude(&mut self) -> f64
Generate the score based on the amplitude of significant interval measurements relative to twice the range of byte. The score is between 0.0 and 1.0. Any score lower than 1.0 should be considered problematic.
( interval_largest ) / 512
§Examples
use bytestat::Bytestat;
let stats = Bytestat::new();
for x in 0..limit {
let my_byte = get_random_byte();
stats.analyze( my_byte );
}
stats.get_score_interval_amplitude()
Sourcepub fn get_score(&mut self) -> f64
pub fn get_score(&mut self) -> f64
Generate the final score based on the 5 individual tests. Score between 0 and 100. 99 or lower is very problematic.
§Examples
use bytestat::Bytestat;
let stats = Bytestat::new();
for x in 0..limit {
let my_byte = get_random_byte();
stats.analyze( my_byte );
}
stats.get_score()
Examples found in repository?
14fn main() {
15
16 let mut stats = Bytestat::new();
17 let mut counter:u128 = 0;
18 let percent = 256 * 4096;
19
20 for x in std::io::stdin().bytes() {
21 match x {
22 Ok(data) => {
23 stats.analyze(data);
24 counter += 1;
25 },
26 Err(err) => {
27 eprintln!("{:?}", err);
28 }
29 }
30 }
31
32 println!("\nRAW SCORES AS STRING");
33 println!("{}", stats.get_scores_string("\n"));
34
35 println!("\nFINAL SCORE");
36 println!("{} samples", counter );
37 println!("{}{:.0}%", if counter < (percent * 100) {"~"} else {""}, stats.get_score() );
38
39}
pub fn get_scores_array(&mut self) -> [f64; 6]
Sourcepub fn get_scores_string(&mut self, seperator: &str) -> String
pub fn get_scores_string(&mut self, seperator: &str) -> String
Examples found in repository?
14fn main() {
15
16 let mut stats = Bytestat::new();
17 let mut counter:u128 = 0;
18 let percent = 256 * 4096;
19
20 for x in std::io::stdin().bytes() {
21 match x {
22 Ok(data) => {
23 stats.analyze(data);
24 counter += 1;
25 },
26 Err(err) => {
27 eprintln!("{:?}", err);
28 }
29 }
30 }
31
32 println!("\nRAW SCORES AS STRING");
33 println!("{}", stats.get_scores_string("\n"));
34
35 println!("\nFINAL SCORE");
36 println!("{} samples", counter );
37 println!("{}{:.0}%", if counter < (percent * 100) {"~"} else {""}, stats.get_score() );
38
39}