Function busyrpc::register_biometrics
source · pub fn register_biometrics(collector: &mut Collector)
Expand description
Register the biometrics for this crate.
Examples found in repository?
examples/busyrpc-benchmark-server.rs (line 28)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
fn main() {
let (options, free) =
BenchmarkOptions::from_command_line("Usage: busyrpc-benchmark-server [OPTIONS]");
if !free.is_empty() {
eprintln!("command takes no arguments");
std::process::exit(1);
}
std::thread::spawn(|| {
let mut collector = Collector::new();
busyrpc::register_biometrics(&mut collector);
let fout = File::create("/dev/stdout").unwrap();
let mut emit = PlainTextEmitter::new(fout);
loop {
let now = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.expect("clock should never fail")
.as_millis()
.try_into()
.expect("millis since epoch should fit u64");
if let Err(e) = collector.emit(&mut emit, now) {
eprintln!("collector error: {}", e);
}
std::thread::sleep(std::time::Duration::from_millis(249));
}
});
let services = ServiceRegistry::new();
let server = Server::new(options.server, services).as_z().pretty_unwrap();
server.serve().as_z().pretty_unwrap();
}
More examples
examples/busyrpc-benchmark-client.rs (line 51)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
fn main() {
let (options, free) =
BenchmarkOptions::from_command_line("Usage: busyrpc-benchmark-client [OPTIONS]");
if !free.is_empty() {
eprintln!("command takes no arguments");
std::process::exit(1);
}
std::thread::spawn(|| {
let mut collector = Collector::new();
busyrpc::register_biometrics(&mut collector);
let fout = File::create("/dev/stdout").unwrap();
let mut emit = PlainTextEmitter::new(fout);
loop {
let now = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.expect("clock should never fail")
.as_millis()
.try_into()
.expect("millis since epoch should fit u64");
if let Err(e) = collector.emit(&mut emit, now) {
eprintln!("collector error: {}", e);
}
std::thread::sleep(std::time::Duration::from_millis(249));
}
});
let client = new_client(options.client, options.connect.clone());
let request_counter = Arc::new(AtomicU64::default());
let mut threads = Vec::new();
for _ in 0..options.threads {
let cl = Arc::clone(&client);
let rc = Arc::clone(&request_counter);
threads.push(std::thread::spawn(move || {
worker(cl, rc, options.rpcs);
}));
}
for thread in threads.into_iter() {
thread.join().unwrap();
}
}