6a7be83efe
- remove chrono dependency - depend on proxmox 0.3.8 - remove epoch_now, epoch_now_u64 and epoch_now_f64 - remove tm_editor (moved to proxmox crate) - use new helpers from proxmox 0.3.8 * epoch_i64 and epoch_f64 * parse_rfc3339 * epoch_to_rfc3339_utc * strftime_local - BackupDir changes: * store epoch and rfc3339 string instead of DateTime * backup_time_to_string now return a Result * remove unnecessary TryFrom<(BackupGroup, i64)> for BackupDir - DynamicIndexHeader: change ctime to i64 - FixedIndexHeader: change ctime to i64
67 lines
1.6 KiB
Rust
67 lines
1.6 KiB
Rust
use std::io::Write;
|
|
|
|
use anyhow::{Error};
|
|
|
|
use proxmox_backup::api2::types::Userid;
|
|
use proxmox_backup::client::{HttpClient, HttpClientOptions, BackupReader};
|
|
|
|
pub struct DummyWriter {
|
|
bytes: usize,
|
|
}
|
|
|
|
impl Write for DummyWriter {
|
|
|
|
fn write(&mut self, data: &[u8]) -> Result<usize, std::io::Error> {
|
|
self.bytes += data.len();
|
|
Ok(data.len())
|
|
}
|
|
|
|
fn flush(&mut self) -> Result<(), std::io::Error> {
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
|
|
async fn run() -> Result<(), Error> {
|
|
|
|
let host = "localhost";
|
|
|
|
let username = Userid::root_userid();
|
|
|
|
let options = HttpClientOptions::new()
|
|
.interactive(true)
|
|
.ticket_cache(true);
|
|
|
|
let client = HttpClient::new(host, username, options)?;
|
|
|
|
let backup_time = proxmox::tools::time::parse_rfc3339("2019-06-28T10:49:48Z")?;
|
|
|
|
let client = BackupReader::start(client, None, "store2", "host", "elsa", backup_time, true)
|
|
.await?;
|
|
|
|
let start = std::time::SystemTime::now();
|
|
|
|
let mut bytes = 0;
|
|
for _ in 0..100 {
|
|
let mut writer = DummyWriter { bytes: 0 };
|
|
client.speedtest(&mut writer).await?;
|
|
println!("Received {} bytes", writer.bytes);
|
|
bytes += writer.bytes;
|
|
}
|
|
|
|
let elapsed = start.elapsed().unwrap();
|
|
let elapsed = (elapsed.as_secs() as f64) +
|
|
(elapsed.subsec_millis() as f64)/1000.0;
|
|
|
|
println!("Downloaded {} bytes, {} MB/s", bytes, (bytes as f64)/(elapsed*1024.0*1024.0));
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn main() {
|
|
if let Err(err) = proxmox_backup::tools::runtime::main(run()) {
|
|
eprintln!("ERROR: {}", err);
|
|
}
|
|
println!("DONE");
|
|
}
|