Hello, I got a chance to be a part of school's competitive programming. I've got a small problem. We have to make a fastest key-value storage possible. That's not an issue. I've got a 170 MB input with instructions like 'Store key value' or 'Output key' or 'Remove key'. How do I read it as fast as possible? I've tried to read it with
fn main() {
let instant = Instant::now();
let mut buffer: Vec<u8> = Vec::with_capacity(200_000_000);
let input = io::stdin();
let mut input_lock = input.lock();
while input_lock.read_until(b'\n', &mut buffer).ok() > Some(0) {
}
println!("Time: {}ms", instant.elapsed().as_millis());
}
but it takes around 300ms which is quite a long time. Fastest time is currently about 800ms but it's reading, executing these operations and outputting the "Output" operation.
I've heard that println is also quite slow, is there any alternative that's also blazingly fast?
PS: My friend was able to read it in 70ms in C++ so it should be also possible in Rust
Thank you for all your help!