Skip to content

Commit

Permalink
bench server start
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Jun 9, 2024
1 parent c429b6b commit cf2a713
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions sa-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
BufReader,
Read
},
sync::Arc
sync::Arc, time::{SystemTime, SystemTimeError, UNIX_EPOCH}
};

use axum::{
Expand Down Expand Up @@ -177,29 +177,33 @@ async fn start_server(args: Arguments) -> Result<(), Box<dyn Error>> {

eprintln!();
eprintln!("πŸ“‹ Started loading the suffix array...");
let start_suffix_time = get_time_ms().unwrap();
let sa = load_suffix_array_file(&index_file)?;
eprintln!("βœ… Successfully loaded the suffix array!");
eprintln!("βœ… Successfully loaded the suffix array in {} seconds!", (get_time_ms().unwrap() - start_suffix_time) / 1000.0);
eprintln!("\tAmount of items: {}", sa.len());
eprintln!("\tAmount of bits per item: {}", sa.bits_per_value());
eprintln!("\tSample rate: {}", sa.sample_rate());

eprintln!();
eprintln!("πŸ“‹ Started loading the taxon file...");
let start_taxon_time = get_time_ms().unwrap();
let taxon_id_calculator =
TaxonAggregator::try_from_taxonomy_file(&taxonomy, AggregationMethod::LcaStar)?;
eprintln!("βœ… Successfully loaded the taxon file!");
eprintln!("βœ… Successfully loaded the taxon file in {} seconds!", (get_time_ms().unwrap() - start_taxon_time) / 1000.0);
eprintln!("\tAggregation method: LCA*");

eprintln!();
eprintln!("πŸ“‹ Started creating the function aggregator...");
let start_function_time = get_time_ms().unwrap();
let function_aggregator = FunctionAggregator {};
eprintln!("βœ… Successfully created the function aggregator!");
eprintln!("βœ… Successfully created the function aggregator in {} seconds!", (get_time_ms().unwrap() - start_function_time) / 1000.0);

eprintln!();
eprintln!("πŸ“‹ Started loading the proteins...");
let start_proteins_time = get_time_ms().unwrap();
let proteins = Proteins::try_from_database_file(&database_file, &taxon_id_calculator)?;
let suffix_index_to_protein = Box::new(SparseSuffixToProtein::new(&proteins.input_string));
eprintln!("βœ… Successfully loaded the proteins!");
eprintln!("βœ… Successfully loaded the proteins in {} seconds!", (get_time_ms().unwrap() - start_proteins_time) / 1000.0);

let searcher = Arc::new(Searcher::new(
sa,
Expand Down Expand Up @@ -251,3 +255,7 @@ fn load_suffix_array_file(file: &str) -> Result<SuffixArray, Box<dyn Error>> {
load_compressed_suffix_array(&mut reader, bits_per_value as usize)
}
}

pub fn get_time_ms() -> Result<f64, SystemTimeError> {
Ok(SystemTime::now().duration_since(UNIX_EPOCH)?.as_nanos() as f64 * 1e-6)
}

0 comments on commit cf2a713

Please sign in to comment.