forked from 0b01/tectonicdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,448 additions
and
1,054 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ test.dtf | |
*.pyc | ||
db | ||
|
||
test/zrx/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,44 +11,54 @@ mod db; | |
|
||
fn main() { | ||
let matches = App::new("tectonic-cli") | ||
.version("0.0.1") | ||
.author("Ricky Han <[email protected]>") | ||
.about("command line client for tectonic financial datastore") | ||
.arg(Arg::with_name("host") | ||
.short("h") | ||
.long("host") | ||
.value_name("HOST") | ||
.help("Sets the host to connect to (default 0.0.0.0)") | ||
.takes_value(true)) | ||
.arg(Arg::with_name("port") | ||
.short("p") | ||
.long("port") | ||
.value_name("PORT") | ||
.help("Sets the port to connect to (default 9001)") | ||
.takes_value(true)) | ||
.arg(Arg::with_name("s") | ||
.short("s") | ||
.long("subscription") | ||
.value_name("DBNAME") | ||
.help("subscribe to the datastore") | ||
.takes_value(true)) | ||
.arg(Arg::with_name("b") | ||
.short("b") | ||
.value_name("ITERATION") | ||
.multiple(false) | ||
.help("Benchmark network latency") | ||
.takes_value(true)) | ||
.get_matches(); | ||
.version("0.0.1") | ||
.author("Ricky Han <[email protected]>") | ||
.about("command line client for tectonic financial datastore") | ||
.arg( | ||
Arg::with_name("host") | ||
.short("h") | ||
.long("host") | ||
.value_name("HOST") | ||
.help("Sets the host to connect to (default 0.0.0.0)") | ||
.takes_value(true), | ||
) | ||
.arg( | ||
Arg::with_name("port") | ||
.short("p") | ||
.long("port") | ||
.value_name("PORT") | ||
.help("Sets the port to connect to (default 9001)") | ||
.takes_value(true), | ||
) | ||
.arg( | ||
Arg::with_name("s") | ||
.short("s") | ||
.long("subscription") | ||
.value_name("DBNAME") | ||
.help("subscribe to the datastore") | ||
.takes_value(true), | ||
) | ||
.arg( | ||
Arg::with_name("b") | ||
.short("b") | ||
.value_name("ITERATION") | ||
.multiple(false) | ||
.help("Benchmark network latency") | ||
.takes_value(true), | ||
) | ||
.get_matches(); | ||
|
||
let host = matches.value_of("host").unwrap_or("0.0.0.0"); | ||
let port = matches.value_of("port").unwrap_or("9001"); | ||
|
||
let mut cxn = db::Cxn::new(host, port).unwrap(); | ||
|
||
if matches.is_present("b") { | ||
let times = matches.value_of("b") .unwrap_or("10") | ||
.parse::<usize>() | ||
.unwrap_or(10) + 1; | ||
let times = matches | ||
.value_of("b") | ||
.unwrap_or("10") | ||
.parse::<usize>() | ||
.unwrap_or(10) + 1; | ||
benchmark(&mut cxn, times); | ||
} else if matches.is_present("s") { | ||
let dbname = matches.value_of("s").unwrap_or(""); | ||
|
@@ -66,13 +76,15 @@ fn benchmark(cxn: &mut db::Cxn, times: usize) { | |
let mut acc = vec![]; | ||
let _create = cxn.cmd("CREATE bnc_gas_btc\n"); | ||
for _ in 1..times { | ||
let _res = cxn.cmd("ADD 1513922718770, 0, t, f, 0.001939, 22.85; INTO bnc_gas_btc\n"); | ||
let _res = cxn.cmd( | ||
"ADD 1513922718770, 0, t, f, 0.001939, 22.85; INTO bnc_gas_btc\n", | ||
); | ||
acc.push(t.elapsed().unwrap().subsec_nanos()); | ||
// println!("res: {:?}, latency: {:?}", res, t.elapsed()); | ||
t = time::SystemTime::now(); | ||
} | ||
|
||
let avg_ns = acc.iter().fold(0, |s,i|s+i) as f32 / acc.len() as f32; | ||
let avg_ns = acc.iter().fold(0, |s, i| s + i) as f32 / acc.len() as f32; | ||
println!("AVG ns/insert: {}", avg_ns); | ||
println!("AVG inserts/s: {}", 1. / (avg_ns / 1_000_000_000.)); | ||
} | ||
|
@@ -88,13 +100,13 @@ fn handle_query(cxn: &mut db::Cxn) { | |
match cxn.cmd(&cmd) { | ||
Err(db::TectonicError::DecodeError) => { | ||
panic!("Decode Error"); | ||
}, | ||
} | ||
Err(db::TectonicError::ConnectionError) => { | ||
panic!("Connection Error"); | ||
}, | ||
} | ||
Err(db::TectonicError::ServerError(msg)) => { | ||
print!("{}", msg); | ||
}, | ||
} | ||
Ok(msg) => { | ||
print!("{}", msg); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,26 +6,29 @@ use libtectonic::dtf; | |
use clap::{Arg, App}; | ||
|
||
fn main() { | ||
let matches = App::new("dtfcat") | ||
.version("1.0.0") | ||
.author("Ricky Han <[email protected]>") | ||
.about("command line client for tectonic financial datastore") | ||
.arg(Arg::with_name("input") | ||
.short("i") | ||
.long("input") | ||
.value_name("INPUT") | ||
.help("file to read") | ||
.required(true) | ||
.takes_value(true)) | ||
.arg(Arg::with_name("metadata") | ||
.short("m") | ||
.long("metadata") | ||
.help("read only the metadata")) | ||
.arg(Arg::with_name("csv") | ||
.short("c") | ||
.long("csv") | ||
.help("output csv (default is JSON)")) | ||
.get_matches(); | ||
let matches = App::new("dtfcat") | ||
.version("1.0.0") | ||
.author("Ricky Han <[email protected]>") | ||
.about("command line client for tectonic financial datastore") | ||
.arg( | ||
Arg::with_name("input") | ||
.short("i") | ||
.long("input") | ||
.value_name("INPUT") | ||
.help("file to read") | ||
.required(true) | ||
.takes_value(true), | ||
) | ||
.arg( | ||
Arg::with_name("metadata") | ||
.short("m") | ||
.long("metadata") | ||
.help("read only the metadata"), | ||
) | ||
.arg(Arg::with_name("csv").short("c").long("csv").help( | ||
"output csv (default is JSON)", | ||
)) | ||
.get_matches(); | ||
|
||
let input = matches.value_of("input").unwrap(); | ||
let metadata = matches.is_present("metadata"); | ||
|
@@ -34,11 +37,17 @@ fn main() { | |
if metadata { | ||
println!("{}", dtf::read_meta(input).unwrap()); | ||
return; | ||
} else if csv{ | ||
println!("{}", dtf::update_vec_to_csv(&dtf::decode(input, None).unwrap())); | ||
} else if csv { | ||
println!( | ||
"{}", | ||
dtf::update_vec_to_csv(&dtf::decode(input, None).unwrap()) | ||
); | ||
return; | ||
} else { | ||
println!("[{}]", dtf::update_vec_to_json(&dtf::decode(input, None).unwrap())); | ||
println!( | ||
"[{}]", | ||
dtf::update_vec_to_json(&dtf::decode(input, None).unwrap()) | ||
); | ||
return; | ||
} | ||
} |
Oops, something went wrong.