Enable tdb-bench to read args and opts from shell

From now on, tdb-bench has to be run with
`tdb-bench -c <c> -q <q> -s <s>` instead of just using positional args.
Also, we'll keep `tdb-bench`'s version in
sync with the version of `tdb`, just like the others in the project

Signed-off-by: Sayan Nandan <nandansayan@outlook.com>
next
Sayan Nandan 4 years ago
parent 477acfab4b
commit 7232fe9189
No known key found for this signature in database
GPG Key ID: C31EFD7DDA12AEE0

3
Cargo.lock generated

@ -543,8 +543,9 @@ dependencies = [
[[package]] [[package]]
name = "tdb-bench" name = "tdb-bench"
version = "0.1.0" version = "0.4.5"
dependencies = [ dependencies = [
"clap",
"devtimer", "devtimer",
"libtdb", "libtdb",
"rand", "rand",

@ -1,6 +1,6 @@
[package] [package]
name = "tdb-bench" name = "tdb-bench"
version = "0.1.0" version = "0.4.5"
authors = ["Sayan Nandan <ohsayan@outlook.com>"] authors = ["Sayan Nandan <ohsayan@outlook.com>"]
edition = "2018" edition = "2018"
@ -9,4 +9,5 @@ edition = "2018"
[dependencies] [dependencies]
rand = "0.7.3" rand = "0.7.3"
devtimer = "4.0.0" devtimer = "4.0.0"
libtdb = {path="../libtdb"} libtdb = {path="../libtdb"}
clap = {version = "2.33.3", features=["yaml"]}

@ -0,0 +1,49 @@
#
# Created on Tue Nov 03 2020
#
# This file is a part of TerrabaseDB
# Copyright (c) 2020, Sayan Nandan <ohsayan at outlook dot com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#
name: TerrabaseDB Benchmark Tool
version: 0.4.5
author: Sayan N. <ohsayan@outlook.com>
about: |
The TerrabaseDB benchmark tool can be used to benchmark TerrabaseDB installations.
If you find any issues, then report one here: https://github.com/terrabasedb/terrabasedb
args:
- connections:
short: c
required: true
long: connections
value_name: count
help: Sets the number of simultaneous clients
takes_value: true
- queries:
short: q
required: true
long: queries
value_name: number
help: Sets the number of queries to run
takes_value: true
- size:
short: s
required: true
long: kvsize
value_name: bytes
help: Sets the size of the key/value pairs
takes_value: true

@ -24,6 +24,7 @@
//! the response times may be shown to be slower than they actually are //! the response times may be shown to be slower than they actually are
mod benchtool { mod benchtool {
use clap::{load_yaml, App};
use devtimer::DevTime; use devtimer::DevTime;
use libtdb::terrapipe; use libtdb::terrapipe;
use rand::distributions::Alphanumeric; use rand::distributions::Alphanumeric;
@ -118,26 +119,12 @@ mod benchtool {
/// Run the benchmark tool /// Run the benchmark tool
pub fn runner() { pub fn runner() {
let mut args: Vec<String> = std::env::args().collect(); let cfg_layout = load_yaml!("./cli.yml");
args.remove(0); let matches = App::from_yaml(cfg_layout).get_matches();
println!(
"------------------------------------------------------------\
\nTerrabaseDB Benchmark Tool v0.1.0\
\nReport issues here: https://github.com/terrabasedb/terrabasedb\
\n------------------------------------------------------------"
);
// connections queries packetsize
if args.len() != 3 {
eprintln!(
"Insufficient arguments!\
\nUSAGE: tdb-bench <connections> <queries> <packetsize-in-bytes>"
);
std::process::exit(0x100);
}
let (max_connections, max_queries, packet_size) = match ( let (max_connections, max_queries, packet_size) = match (
args[0].parse::<usize>(), matches.value_of("connections").unwrap().parse::<usize>(),
args[1].parse::<usize>(), matches.value_of("queries").unwrap().parse::<usize>(),
args[2].parse::<usize>(), matches.value_of("size").unwrap().parse::<usize>(),
) { ) {
(Ok(mx), Ok(mc), Ok(ps)) => (mx, mc, ps), (Ok(mx), Ok(mc), Ok(ps)) => (mx, mc, ps),
_ => { _ => {

Loading…
Cancel
Save