mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Benchmark suite includes local socket round-trip.
This commit is contained in:
12
src/rust/Cargo.lock
generated
12
src/rust/Cargo.lock
generated
@@ -253,15 +253,6 @@ version = "3.11.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bus_benchmark"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"lqos_bus",
|
|
||||||
"tokio",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.4.3"
|
version = "1.4.3"
|
||||||
@@ -449,6 +440,7 @@ dependencies = [
|
|||||||
"clap 2.34.0",
|
"clap 2.34.0",
|
||||||
"criterion-plot",
|
"criterion-plot",
|
||||||
"csv",
|
"csv",
|
||||||
|
"futures",
|
||||||
"itertools",
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
@@ -461,6 +453,7 @@ dependencies = [
|
|||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tinytemplate",
|
"tinytemplate",
|
||||||
|
"tokio",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1285,6 +1278,7 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"bincode",
|
"bincode",
|
||||||
"cc",
|
"cc",
|
||||||
|
"criterion",
|
||||||
"lqos_config",
|
"lqos_config",
|
||||||
"serde",
|
"serde",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
|||||||
@@ -21,5 +21,4 @@ members = [
|
|||||||
"lqos_node_manager", # A lightweight web interface for management and local monitoring
|
"lqos_node_manager", # A lightweight web interface for management and local monitoring
|
||||||
"lqos_python", # Python bindings for using the Rust bus directly
|
"lqos_python", # Python bindings for using the Rust bus directly
|
||||||
"webusers", # CLI control for managing the web user list
|
"webusers", # CLI control for managing the web user list
|
||||||
"bus_benchmark", # Simple tool to measure the overall latency of using our local socket connection
|
|
||||||
]
|
]
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "bus_benchmark"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
lqos_bus = { path = "../lqos_bus" }
|
|
||||||
tokio = { version = "1.22", features = [ "rt", "macros", "net", "io-util" ] }
|
|
||||||
anyhow = "1"
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
use std::time::Instant;
|
|
||||||
use anyhow::Result;
|
|
||||||
use lqos_bus::{bus_request, BusRequest};
|
|
||||||
|
|
||||||
#[tokio::main(flavor = "current_thread")]
|
|
||||||
pub async fn main() -> Result<()> {
|
|
||||||
const RUNS: usize = 100;
|
|
||||||
|
|
||||||
println!("Sending {RUNS} bus pings, please wait.");
|
|
||||||
let mut times = Vec::new();
|
|
||||||
for _ in 0 .. RUNS {
|
|
||||||
let now = Instant::now();
|
|
||||||
let responses = bus_request(vec![BusRequest::Ping]).await?;
|
|
||||||
let runtime = now.elapsed();
|
|
||||||
assert_eq!(responses.len(), 1);
|
|
||||||
times.push(runtime);
|
|
||||||
}
|
|
||||||
let sum_usec: u128 = times.iter().map(|t| t.as_nanos()).sum();
|
|
||||||
let avg_usec = sum_usec / RUNS as u128;
|
|
||||||
println!("Average bus time: {avg_usec} nanoseconds");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,7 @@ tokio = { version = "1.22", features = [ "rt", "macros", "net", "io-util" ] }
|
|||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
criterion = { version = "0.3", features = [ "html_reports"] }
|
criterion = { version = "0.3", features = [ "html_reports", "async_tokio"] }
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "socket"
|
name = "socket"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//! Benchmarks for JSON serialization and gathering data from TC.
|
//! Becnhmarks for the bus system, mostly focused on serialization
|
||||||
//! Please select an interface in `test_interface.txt` (no enter character
|
//! but also including sockets.
|
||||||
//! at the end). This benchmark will destructively clear and then create
|
//!
|
||||||
//! TC queues - so don't select an interface that you need!
|
//! You MUST have lqosd running when you perform these tests.
|
||||||
|
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
use lqos_bus::*;
|
use lqos_bus::*;
|
||||||
@@ -52,6 +52,19 @@ pub fn criterion_benchmark(c: &mut Criterion) {
|
|||||||
black_box(result);
|
black_box(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Enable the Tokio runtime to test round-trip
|
||||||
|
let tokio_rt = tokio::runtime::Builder::new_current_thread()
|
||||||
|
.enable_io()
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
c.bench_function("bus_ping_round_trip", |b| {
|
||||||
|
b.iter(|| {
|
||||||
|
let result = tokio_rt.block_on(bus_request(vec![BusRequest::Ping])).unwrap();
|
||||||
|
black_box(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
criterion_group!(benches, criterion_benchmark);
|
criterion_group!(benches, criterion_benchmark);
|
||||||
|
|||||||
Reference in New Issue
Block a user