fast-sqlite3-inserts
                                
                                 fast-sqlite3-inserts copied to clipboard
                                
                                    fast-sqlite3-inserts copied to clipboard
                            
                            
                            
                        Try reusing memory
Fix #10
Unsafe is probably not nice but I am not sure how to satisfy borrow checker there. I tried using mem::swap and related functions but it still seemed like the borrow checker does not know that the reference is not longer valid when vec.clear().
29s -> 27s
Is it possible to avoid unsafe in this?
Is it possible to avoid unsafe in this?
I can't think of anything to help avoid these unsafe here, but I'm not a Rust expert, so...
One thing I tried to do was using named_params!,
for batch in values.iter() {
    let (a,b,c) = batch;
    row_values.push(named_params!{":area": a, ":age": b, ":active": c});
}
but Params is not implemented for &[&[(&str, &dyn ToSql)]], which is the slice from the row_values.
I switched to use https://docs.rs/rsor/0.1.2/rsor/ rsor library as suggested by @upsuper (he suggested a related library with runtime checks). std does not provide these tools and it only have compile-time cost.
I ran it and I did not see much difference:
./bench.sh
Sun Aug  8 14:06:19 IST 2021 [RUST] basic_batched.rs (100_000_000) inserts
real	0m30.255s
user	0m27.745s
sys	0m2.247s
What's the difference? 1s?
@pickfire yup, seems so.
Yeah, but it's consistent 1s and reduced memory allocation, I am not sure how good the effect will be on other parts.