use log::*;
use sanakirja::environment::*;
use sanakirja_core::btree::*;
use sanakirja_core::btree;
use sanakirja_core::*;
// mod parallel_benchmark;
mod debug;
fn main() {
env_logger::init();
main::main();
// main::parallel_benchmark();
}
#[derive(Eq, PartialEq, PartialOrd, Ord)]
struct A<T>([u64; 100], std::marker::PhantomData<T>);
impl<T> std::fmt::Debug for A<T> {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(fmt, "A(…)")?;
Ok(())
}
}
impl<T> Representable<T> for A<T> {
type PageOffsets = core::iter::Empty<u64>;
fn page_offsets(&self) -> Self::PageOffsets {
core::iter::empty()
}
const ALIGN: usize = core::mem::align_of::<Self>();
const SIZE: Option<usize> = Some(core::mem::size_of::<Self>());
type Ord = [u64; 100];
fn ord(&self, _: &T) -> &Self::Ord {
&self.0
}
fn size(&self) -> usize {
core::mem::size_of::<Self>()
}
}
type T<'a> = MutTxn<&'a Env<Exclusive>, ()>;
mod main {
use super::*;
#[test]
pub fn main() {
env_logger::try_init().unwrap_or(());
let env = Env::new_anon(409600000).unwrap();
let mut txn = Env::mut_txn_begin(&env).unwrap();
let now = std::time::SystemTime::now();
for i in 0..n {
debug!("put {:?}", i);
}
println!("moi: {:?}", now.elapsed());
let mut btree = std::collections::BTreeMap::new();
let now = std::time::SystemTime::now();
for i in 0..n {
}
println!("std: {:?}", now.elapsed());
/*
std::mem::forget(txn);
{
let env = EnvBuilder::new()
.map_size(1 << 27)
.open("test-lmdb", 0o777)
.unwrap();
let db_handle = env.get_default_db(DbFlags::empty()).unwrap();
let txn = env.new_transaction().unwrap();
{
let db = txn.bind(&db_handle); // get a database bound to this transaction
let now = std::time::SystemTime::now();
for i in 0..n {
db.set(&(i * i), &(i * i * i)).unwrap();
}
println!("lmdb: {:?}", now.elapsed());
}
}
*/
}
}
*/
btree.insert(i * i, i * i * i);
let i = 500;
debug!("deleting {:?}", (i*i)%1_000_000);
del(&mut txn, &mut db, &((i * i) % 1_000_000), None).unwrap();
debug::debug(&txn, &db, "debug", true);
/*
let a = A([i * i * i; 100], std::marker::PhantomData);
put(&mut txn, &mut db, &((i * i) % 1_000_000), &a).unwrap();
let mut db = create_db::<MutTxn<&Env<Exclusive>, ()>, u64, A<T>, B<T>>(&mut txn).unwrap();
let n = 501;
type B<T> = btree::page::Page<u64, A<T>>;