//! Testing the CORBA device backend.

use std::time::Instant;

use tango::dev::DevProxy;

use tango::zeromq::ZmqEventBackend;
use tango::omniorb::CorbaBackend;
use tracing::info;


#[tokio::main]
async fn main() {

    tracing_subscriber::fmt()
        .with_target(false)
        .with_env_filter(tracing_subscriber::EnvFilter::builder()
            .with_default_directive(tracing_subscriber::filter::LevelFilter::DEBUG.into())
            .from_env_lossy())
        .init();

    CorbaBackend::init().unwrap().register();
    ZmqEventBackend::init().await.unwrap().register();

    let univ_dev = DevProxy::new("127.0.0.1:56467/sys/bench/1#dbase=no");

    info!("Start loop...");
    let iterations = 10000u32;
    let now = Instant::now();
    for _ in 0..iterations {
        univ_dev.ping().await.unwrap();
        // univ_dev.read_many_attr("DevStringRO").await.unwrap();
    }
    let duration = now.elapsed();
    let average_duration = duration.checked_div(iterations);
    info!(?average_duration, "Finished loop");

    std::future::pending::<()>().await;
    unreachable!();

}
