#programming
Here's a micro benchmark I used to measure rust vs c++ performance my way. Create a hashmap 500k sized. And populate it with strings 5m times. Thus overwriting the old values with new values 10 times over.
It measures hashmap implementation, string concatenation, and GC speed.
Result : c++ version is 30% faster while using half the memory of Rust.
Code, compile and test runs bellow. Used /usr/bin/time -v for memory and time measurements.
[habib@msi map]$ cat rustmap.rs
use std::collections::HashMap;
fn main(){
let mut ret = HashMap::new();
for i in 0..5000000 {
ret.insert(format!("id.{}", i%500000), format!("val.{}",i));
}
println!("{}", ret.len());
match ret.get("id.10000") {
Some(val) => println!("{}", val),
None => println!("ERROR")
}
}
[habib@msi map]$ cat cppmap.cpp
#include
#include