600x faster than postgres apparently

This commit is contained in:
Tove 2023-06-19 09:21:41 +02:00
parent c7d6014c87
commit 99f999330b
Signed by: TudbuT
GPG key ID: 7D63D5634B7C417F
3 changed files with 24 additions and 4 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "microdb"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
description = "A very small in-program database with cache, disk storage, etc."
license = "MIT"

View file

@ -1,10 +1,15 @@
# MicroDB
A microsized database for use in programs with too much data for the RAM, but not necessarily for your
next incredibly successful Discord clone (tho I suppose you could make that work too\*).
A microsized database for use in programs with too much data for the RAM, ~~but not necessarily for your
next incredibly successful Discord clone (tho I suppose you could make that work too)~~\* (correction below).
\* So it turns out when I compared this against postgres in terms of speed, THIS WON BY MILES. And by miles,
I mean a factor of about 16 (0.067ms vs 0.0004ms).
I mean a factor of about 160\*2 (0.067ms vs 0.0004ms). So I suppose you can actually use this for your next
Discord clone.
\*2 So it turns out when I compared this here, I actually gave postgres an advantage! If I just access the items
as booleans (a RawObj), I get a factor of 600! (0.067ms vs 0.0001ms).
I'm honestly not sure how to react to this, but alright, I like it.
## Completed features

View file

@ -76,6 +76,21 @@ fn main() {
elapsed,
elapsed as f64 / 10000.0
);
println!("\nSetting test --raw--> true");
db.set_raw("test", true).unwrap();
let v: bool = db.get_raw("test").unwrap().unwrap();
assert_eq!(v, true);
let time = SystemTime::now();
println!("Reading test 10000 times.");
for _ in 0..10000 {
black_box::<bool>(db.get_raw("test").unwrap().unwrap());
}
let elapsed = time.elapsed().unwrap().as_millis();
println!(
"Done! Took {}ms: {}ms per read.",
elapsed,
elapsed as f64 / 10000.0
);
println!("\nSetting test --com--> vec![true; 500]");
db.set_com("test", vec![true; 500]).unwrap();
let v: Vec<bool> = db.get_com("test").unwrap().unwrap();