diff --git a/TODO integration tests for ALL regular and byte_string functions.txt b/TODO integration tests for ALL regular and byte_string functions.txt new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/TODO integration tests for ALL regular and byte_string functions.txt @@ -0,0 +1 @@ + diff --git a/src/anslatortray.rs b/src/anslatortray.rs index 2dd886f..061dc72 100644 --- a/src/anslatortray.rs +++ b/src/anslatortray.rs @@ -135,26 +135,19 @@ fn benchmark_file(args: &Vec) { let file_contents = std::fs::read_to_string(input_file).unwrap(); - let mut total_duration_utf8 = std::time::Duration::new(0, 0); + let mut total_duration_regular = std::time::Duration::new(0, 0); for _ in 0..iterations { let start_time = std::time::Instant::now(); let translated_file_contents = translate(&file_contents); let time_to_translate = start_time.elapsed(); - total_duration_utf8 += time_to_translate; + total_duration_regular += time_to_translate; std::fs::write("/dev/null", &translated_file_contents).unwrap();//TODO avoid needing unix } - eprintln!("Sucessful: UTF-8 translation took {}ns to translate on average over {} runs.", total_duration_utf8.as_nanos() / iterations, iterations); + eprintln!("Sucessful: Regular translation took {}ns to translate on average over {} runs.", total_duration_regular.as_nanos() / iterations, iterations); - for character in file_contents.chars() { - if !character.is_ascii() { - eprintln!("Not performing ASCII translation benchmarks as the file's contents are not entirely ASCII."); - return; - } - } - - let mut total_duration_ascii = std::time::Duration::new(0, 0); + let mut total_duration_byte_string = std::time::Duration::new(0, 0); let mut translated_file_contents = Vec::::new();//TODO set a sane initial size for _ in 0..iterations { @@ -162,10 +155,10 @@ fn benchmark_file(args: &Vec) { translated_file_contents.truncate(0); byte_string::translate(file_contents.as_bytes(), &mut translated_file_contents); let time_to_translate = start_time.elapsed(); - total_duration_ascii += time_to_translate; + total_duration_byte_string += time_to_translate; std::fs::write("/dev/null", &translated_file_contents).unwrap();//TODO avoid needing unix } - eprintln!("Sucessful: ASCII translation took {}ns to translate on average over {} runs.", total_duration_ascii.as_nanos() / iterations, iterations); + eprintln!("Sucessful: Byte-string translation with reused allocations took {}ns to translate on average over {} runs.", total_duration_byte_string.as_nanos() / iterations, iterations); } fn translate_args(args: &Vec) { diff --git a/src/byte_string.rs b/src/byte_string.rs index 5f4d92f..44be6ff 100644 --- a/src/byte_string.rs +++ b/src/byte_string.rs @@ -70,7 +70,6 @@ pub fn translate_with_style(english: &[u8], suffix_lower: &[u8], special_case_su translate_with_style_lower_and_upper_suffixes(english, suffix_lower, special_case_suffix_lower, &suffix_upper, &special_case_suffix_upper, pig_latin_string); } -//TODO tests for this function pub(crate) fn translate_with_style_lower_and_upper_suffixes ( english: &[u8], suffix_lower: &[u8], special_case_suffix_lower: &[u8], suffix_upper: &[u8], special_case_suffix_upper: &[u8], @@ -267,7 +266,6 @@ mod tests { //NOTE: We don't test byte_string::translate_with_style and other similar functions in here directly since we test them through string.rs //TODO test uppercase words - #[test] fn test_translate_word_with_style() { let suffix_special_case_suffix_pairs = [