-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomparison.rs
57 lines (49 loc) · 1.89 KB
/
comparison.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#![allow(dead_code)]
use anyhow::Result;
use chrono::{DateTime, DurationRound, Utc};
use deadpool_postgres::Client;
use std::collections::HashMap;
use std::str::FromStr;
use std::time::{Duration, Instant, SystemTime};
use tokio_postgres::binary_copy::BinaryCopyInWriter;
use tokio_postgres::types::{ToSql, Type};
mod comparison {
use super::*;
pub mod pco;
pub mod pco_store;
pub mod postgres;
}
use comparison::*;
static DB_POOL: std::sync::LazyLock<std::sync::Arc<deadpool_postgres::Pool>> = std::sync::LazyLock::new(|| {
let url = std::env::var("DATABASE_URL").unwrap_or("postgresql://localhost:5432/postgres".to_string());
let pg_config = tokio_postgres::Config::from_str(&url).unwrap();
let mgr_config = deadpool_postgres::ManagerConfig { recycling_method: deadpool_postgres::RecyclingMethod::Fast };
let mgr = deadpool_postgres::Manager::from_config(pg_config, tokio_postgres::NoTls, mgr_config);
deadpool_postgres::Pool::builder(mgr).build().unwrap().into()
});
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
println!("====== comparison");
println!("== pco");
let start = Instant::now();
pco::store().await?;
println!("compressed after {:.1?}", start.elapsed());
let start = Instant::now();
pco::load().await?;
println!("decompressed after {:.1?}", start.elapsed());
println!("== pco_store");
let start = Instant::now();
pco_store::store().await?;
println!("compressed after {:.1?}", start.elapsed());
let start = Instant::now();
pco_store::load().await?;
println!("decompressed after {:.1?}", start.elapsed());
println!("== postgres");
let start = Instant::now();
postgres::store().await?;
println!("compressed after {:.1?}", start.elapsed());
let start = Instant::now();
postgres::load().await?;
println!("decompressed after {:.1?}", start.elapsed());
Ok(())
}