//! Benchmarks for translation systems use criterion::{Criterion, Throughput, black_box, criterion_group, criterion_main}; use rtx_nlg::translation::*; fn bench_translation_speed(c: &mut Criterion) { let mut group = c.benchmark_group("translation"); group.throughput(Throughput::Elements(1)); let config = TranslationConfig::new("en", "es") .beam_size(4) .max_length(100); let translator = Translator::new(config).unwrap(); let test_texts = [ "Hello world", "This is a longer sentence for translation testing", "Machine translation is an important application of natural language processing that enables automatic translation between different human languages.", ]; for (i, text) in test_texts.iter().enumerate() { group.bench_with_input( format!("length_{}", text.split_whitespace().count()), text, |b, text| { b.iter(|| { let result = translator.translate(black_box(text)).unwrap(); black_box(result); }); }, ); } group.finish(); } criterion_group!(translation_benches, bench_translation_speed); criterion_main!(translation_benches);