+use std::str::FromStr;
+
use anyhow::Error;
use futures::*;
extern crate proxmox_backup;
-use pbs_client::ChunkStream;
+use pbs_client::{ChunkStream, FixedChunkStream};
+use proxmox_human_byte::HumanByte;
// Test Chunker with real data read from a file.
//
async fn run() -> Result<(), Error> {
let file = tokio::fs::File::open("random-test.dat").await?;
- let stream = tokio_util::codec::FramedRead::new(file, tokio_util::codec::BytesCodec::new())
- .map_ok(|bytes| bytes.to_vec())
- .map_err(Error::from);
+ let mut args = std::env::args();
+ args.next();
+
+ let buffer_size = args.next().unwrap_or("8k".to_string());
+ let buffer_size = HumanByte::from_str(&buffer_size)?;
+ println!("Using buffer size {buffer_size}");
+
+ let stream = tokio_util::codec::FramedRead::with_capacity(
+ file,
+ tokio_util::codec::BytesCodec::new(),
+ buffer_size.as_u64() as usize,
+ )
+ .map_err(Error::from);
//let chunk_stream = FixedChunkStream::new(stream, 4*1024*1024);
let mut chunk_stream = ChunkStream::new(stream, None, None, None);
repeat += 1;
stream_len += chunk.len();
- println!("Got chunk {}", chunk.len());
+ //println!("Got chunk {}", chunk.len());
}
let speed =