Fix benchtool::runner not using max_connections

At the same time, several expressions were simplified.
next
Sayan Nandan 3 years ago
parent 827a4afff2
commit be087f0c84

@ -45,18 +45,20 @@ pub fn runner(
json_out: bool,
) {
sanity_test!(host, port);
eprintln!(
if !json_out {
println!(
"Initializing benchmark\nConnections: {}\nQueries: {}\nData size (key+value): {} bytes",
max_connections,
max_queries,
(packet_size * 2), // key size + value size
);
}
let host = hoststr!(host, port);
let mut rand = thread_rng();
let mut dt = DevTime::new_complex();
// Create separate connection pools for get and set operations
let mut setpool = Workpool::new(
10,
max_connections,
move || TcpStream::connect(host.clone()).unwrap(),
|sock, packet: Vec<u8>| {
sock.write_all(&packet).unwrap();
@ -94,9 +96,11 @@ pub fn runner(
let del_packs: Vec<Vec<u8>> = (0..max_queries)
.map(|idx| libsky::into_raw_query(&format!("DEL {}", keys[idx])))
.collect();
eprintln!("Per-packet size (GET): {} bytes", get_packs[0].len());
eprintln!("Per-packet size (SET): {} bytes", set_packs[0].len());
eprintln!("Initialization complete! Benchmark started");
if !json_out {
println!("Per-packet size (GET): {} bytes", get_packs[0].len());
println!("Per-packet size (SET): {} bytes", set_packs[0].len());
println!("Initialization complete! Benchmark started");
}
dt.create_timer("SET").unwrap();
dt.start_timer("SET").unwrap();
for packet in set_packs {
@ -111,7 +115,9 @@ pub fn runner(
}
drop(getpool);
dt.stop_timer("GET").unwrap();
eprintln!("Benchmark completed! Removing created keys...");
if !json_out {
println!("Benchmark completed! Removing created keys...");
}
// Create a connection pool for del operations
// Delete all the created keys
for packet in del_packs {

@ -31,7 +31,10 @@
mod benchtool;
mod testkey;
mod util;
use crate::util::DEFAULT_PACKET_SIZE;
use crate::util::DEFAULT_QUERY_COUNT;
use crate::util::DEFAULT_WORKER_COUNT;
// external imports
use clap::{load_yaml, App};
use core::hint::unreachable_unchecked;
@ -50,25 +53,20 @@ fn main() {
None => 2003,
};
let json_out = matches.is_present("json");
let max_connections = match matches
.value_of("connections")
.unwrap_or("10")
.parse::<usize>()
{
Ok(con) => con,
Err(_) => err!("Bad value for maximum connections"),
let max_connections = match matches.value_of("connections").map(|v| v.parse::<usize>()) {
Some(Ok(con)) => con,
None => DEFAULT_WORKER_COUNT,
_ => err!("Bad value for maximum connections"),
};
let max_queries = match matches
.value_of("queries")
.unwrap_or("100000")
.parse::<usize>()
{
Ok(qr) => qr,
Err(_) => err!("Bad value for max queries"),
let max_queries = match matches.value_of("queries").map(|v| v.parse::<usize>()) {
Some(Ok(qr)) => qr,
None => DEFAULT_QUERY_COUNT,
_ => err!("Bad value for max queries"),
};
let packet_size = match matches.value_of("size").unwrap_or("4").parse::<usize>() {
Ok(size) => size,
Err(_) => err!("Bad value for key/value size"),
let packet_size = match matches.value_of("size").map(|v| v.parse::<usize>()) {
Some(Ok(size)) => size,
None => DEFAULT_PACKET_SIZE,
_ => err!("Bad value for key/value size"),
};
if let Some(cmd) = matches.subcommand_matches("testkey") {
let count = match cmd.value_of_lossy("count") {

@ -29,6 +29,10 @@ use rand::thread_rng;
use serde::Serialize;
use std::error::Error;
pub const DEFAULT_WORKER_COUNT: usize = 10;
pub const DEFAULT_PACKET_SIZE: usize = 8;
pub const DEFAULT_QUERY_COUNT: usize = 100_000;
#[macro_export]
macro_rules! hoststr {
($host:expr, $port:expr) => {{

Loading…
Cancel
Save