mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-25 06:00:08 +01:00
feat: Output more informations from the examples on document injection
This commit is contained in:
parent
788fae59a1
commit
5040095228
@ -37,7 +37,8 @@ pub struct Database {
|
||||
impl Database {
|
||||
pub fn start_default<P: AsRef<Path>>(path: P) -> Result<Database, Error> {
|
||||
let cache = RwLock::new(HashMap::new());
|
||||
let inner = sled::Db::start_default(path)?;
|
||||
let config = sled::ConfigBuilder::new().path(path).print_profile_on_drop(true).build();
|
||||
let inner = sled::Db::start(config)?;
|
||||
Ok(Database { cache, inner })
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,13 @@ tide = "0.2.0"
|
||||
|
||||
[dev-dependencies]
|
||||
csv = "1.0.7"
|
||||
diskus = "0.5.0"
|
||||
env_logger = "0.6.1"
|
||||
jemallocator = "0.1.9"
|
||||
meilidb-core = { path = "../meilidb-core", version = "0.1.0" }
|
||||
quickcheck = "0.8.2"
|
||||
rand = "0.6.5"
|
||||
rand_xorshift = "0.1.1"
|
||||
structopt = "0.2.15"
|
||||
sysinfo = "0.8.4"
|
||||
termcolor = "1.0.4"
|
||||
|
@ -2,13 +2,15 @@
|
||||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::io::{self, BufRead, BufReader};
|
||||
use std::io::{self, Write, BufRead, BufReader};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::Instant;
|
||||
use std::error::Error;
|
||||
use std::borrow::Cow;
|
||||
use std::fs::File;
|
||||
|
||||
use diskus::Walk;
|
||||
use sysinfo::{SystemExt, ProcessExt};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use structopt::StructOpt;
|
||||
|
||||
@ -52,6 +54,11 @@ fn index(
|
||||
{
|
||||
let database = Database::start_default(database_path)?;
|
||||
|
||||
let mut wtr = csv::Writer::from_path("./stats.csv").unwrap();
|
||||
wtr.write_record(&["NumberOfDocuments", "DiskUsed", "MemoryUsed"])?;
|
||||
|
||||
let mut system = sysinfo::System::new();
|
||||
|
||||
let index = database.create_index("default", schema.clone())?;
|
||||
|
||||
let mut rdr = csv::Reader::from_path(csv_data_path)?;
|
||||
@ -90,6 +97,13 @@ fn index(
|
||||
|
||||
println!("committing update...");
|
||||
update.finalize()?;
|
||||
|
||||
// write stats
|
||||
let directory_size = Walk::new(&[database_path.to_owned()], 4).run();
|
||||
system.refresh_all();
|
||||
let memory = system.get_process(sysinfo::get_current_pid()).unwrap().memory(); // in kb
|
||||
wtr.write_record(&[i.to_string(), directory_size.to_string(), memory.to_string()])?;
|
||||
wtr.flush()?;
|
||||
}
|
||||
|
||||
Ok(database)
|
||||
|
Loading…
x
Reference in New Issue
Block a user