对比C++的hashmap和hashbrown hashmap
mod main2;
use std::collections::HashMap;
use chrono::prelude::*;
fn test2() {
// 创建一个HashMap,用于存储宝石种类和对应的数量
let mut my_gems = HashMap::new();
for i in 0..10000000 {
// 将宝石类型和对应的数量写入表中
my_gems.insert(i, 1);
}
}
fn test1() {
let mut map = hashbrown::HashMap::new();
for i in 0..10000000 {
map.insert(i, "one");
}
}
fn main() {
println!("asdfasf111");
let startdt = Local::now();
let start=startdt.timestamp_millis();
test2();
let enddt = Local::now();
let end=enddt.timestamp_millis();
println!("dt: {}", (end-start));
let startdt = Local::now();
let start=startdt.timestamp_millis();
test1();
let enddt = Local::now();
let end=enddt.timestamp_millis();
println!("dt: {}", (end-start));
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)