Skip to content

Commit adbcea7

Browse files
committed
add timing output
1 parent b1f5aed commit adbcea7

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/bin/brotli.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ pub fn compress_multi<InputType:Read,
373373
}
374374
}
375375

376+
use std::time::{Duration, SystemTime};
377+
376378
pub fn compress<InputType, OutputType>(r: &mut InputType,
377379
w: &mut OutputType,
378380
buffer_size: usize,
@@ -381,6 +383,7 @@ pub fn compress<InputType, OutputType>(r: &mut InputType,
381383
num_threads: usize) -> Result<usize, io::Error>
382384
where InputType: Read,
383385
OutputType: Write {
386+
let now = SystemTime::now();
384387
if num_threads > 1 && custom_dictionary.len() ==0 && !params.log_meta_block {
385388
if has_stdlib() {
386389
return compress_multi(r, w, params, num_threads, Some(&mut new_work_pool(num_threads - 1)));
@@ -408,6 +411,7 @@ pub fn compress<InputType, OutputType>(r: &mut InputType,
408411
if params.log_meta_block {
409412
println_stderr!("window {} 0 0 0", params.lgwin);
410413
}
414+
let result =
411415
brotli::BrotliCompressCustomIoCustomDict(&mut IoReaderWrapper::<InputType>(r),
412416
&mut IoWriterWrapper::<OutputType>(w),
413417
&mut input_buffer.slice_mut(),
@@ -416,7 +420,17 @@ pub fn compress<InputType, OutputType>(r: &mut InputType,
416420
new_brotli_heap_alloc(),
417421
&mut log,
418422
custom_dictionary,
419-
Error::new(ErrorKind::UnexpectedEof, "Unexpected EOF"))
423+
Error::new(ErrorKind::UnexpectedEof, "Unexpected EOF"));
424+
match now.elapsed() {
425+
Ok(elapsed) => {
426+
println!("elapsed: {}", elapsed.as_secs());
427+
}
428+
Err(e) => {
429+
println!("Error: {:?}", e);
430+
}
431+
}
432+
result
433+
420434
}
421435

422436
// This decompressor is defined unconditionally on whether std is defined

0 commit comments

Comments
 (0)