Ticket #24031: main.rs

File main.rs, 813 bytes (added by isis, 6 weeks ago)
Line 
1use std::collections::HashMap;
2use std::collections::HashSet;
3use std::mem::size_of;
4
5fn main() {
6    let mut map: HashMap<String, HashSet<u32>> = HashMap::new();
7    let mut size: usize = size_of::<HashMap<String, HashSet<u32>>>();
8
9    let protocols = ["Link", "LinkAuth", "Relay", "HSIntro", "HSRend",
10                     "HSDir", "DirCache", "Desc", "Microdesc", "Cons"];
11
12    for proto in protocols.iter() {
13        size += size_of::<char>() * proto.len();
14
15        let mut set: HashSet<u32> = HashSet::new();
16        size += size_of::<HashSet<u32>>();
17
18        for i in 1..65536 {
19            set.insert(i as u32);
20            size += size_of::<u32>();
21        }
22        map.insert(proto.to_string(), set);
23        size += size_of::<String>();
24    }
25    println!("size is: {} KB", size as f32 / 1024. );
26}