(expr: &str, n_loops: usize)
| 261 | } |
| 262 | |
| 263 | fn timing_test(expr: &str, n_loops: usize) { |
| 264 | if n_loops == 0 { |
| 265 | return; |
| 266 | } |
| 267 | |
| 268 | let n_loops_float = n_loops as f64; |
| 269 | let instant = Instant::now(); |
| 270 | for _ in 0..n_loops { |
| 271 | if let Err(e) = set_mathml(expr.to_string()) { |
| 272 | panic!("Error: exiting -- {}", errors_to_string(&e)); |
| 273 | }; |
| 274 | match get_spoken_text() { |
| 275 | Ok(_) =>( ), |
| 276 | Err(e) => panic!("{}", errors_to_string(&e)), |
| 277 | } |
| 278 | match get_braille("".to_string()) { |
| 279 | Ok(_) => (), |
| 280 | Err(e) => panic!("{}", errors_to_string(&e)), |
| 281 | } |
| 282 | } |
| 283 | info!("Time taken (time for set, speech, {} braille averaged over 100 loops): {}ms", get_preference("BrailleCode".to_string()).unwrap(), instant.elapsed().as_millis() as f64/n_loops_float); |
| 284 | |
| 285 | let instant = Instant::now(); |
| 286 | for _ in 0..n_loops { |
| 287 | if let Err(e) = set_mathml(expr.to_string()) { |
| 288 | panic!("Error: exiting -- {}", errors_to_string(&e)); |
| 289 | }; |
| 290 | } |
| 291 | info!("Time taken (time for set averaged over 100 loops): {}ms", instant.elapsed().as_millis() as f64/n_loops_float); |
| 292 | |
| 293 | let instant = Instant::now(); |
| 294 | for _ in 0..n_loops { |
| 295 | match get_spoken_text() { |
| 296 | Ok(_) =>( ), |
| 297 | Err(e) => panic!("{}", errors_to_string(&e)), |
| 298 | } |
| 299 | } |
| 300 | info!("Time taken (time for speech averaged over 100 loops): {}ms", instant.elapsed().as_millis() as f64/n_loops_float); |
| 301 | |
| 302 | set_preference("BrailleCode".to_string(), "Nemeth".to_string()).unwrap(); |
| 303 | get_braille("".to_string()).unwrap(); |
| 304 | let instant = Instant::now(); |
| 305 | for _ in 0..n_loops { |
| 306 | match get_braille("".to_string()) { |
| 307 | Ok(_) => (), |
| 308 | Err(e) => panic!("{}", errors_to_string(&e)), |
| 309 | } |
| 310 | } |
| 311 | info!("Time taken (time for {} braille averaged over 100 loops): {}ms", get_preference("BrailleCode".to_string()).unwrap(), instant.elapsed().as_millis() as f64/n_loops_float); |
| 312 | |
| 313 | set_preference("BrailleCode".to_string(), "UEB".to_string()).unwrap(); |
| 314 | get_braille("".to_string()).unwrap(); |
| 315 | let instant = Instant::now(); |
| 316 | for _ in 0..n_loops { |
| 317 | match get_braille("".to_string()) { |
| 318 | Ok(_) => (), |
| 319 | Err(e) => panic!("{}", errors_to_string(&e)), |
| 320 | } |
no test coverage detected