| 109 | // ============================================================================ |
| 110 | |
| 111 | fn generate_world() -> WorldState { |
| 112 | print!("Generating Complex World... "); |
| 113 | let start = Instant::now(); |
| 114 | |
| 115 | // 1. Users Map (Heavy Map) |
| 116 | let mut users = HashMap::new(); |
| 117 | for i in 0..100_000 { |
| 118 | users.insert( |
| 119 | i, |
| 120 | UserProfile { |
| 121 | username: format!("Player_{}", i), |
| 122 | xp: i * 100, |
| 123 | bio: "A very long description tailored to fill some bytes in the bucket.".into(), |
| 124 | }, |
| 125 | ); |
| 126 | } |
| 127 | |
| 128 | // 2. Deep Hierarchy (World -> Regions -> Zones -> Data) |
| 129 | let regions = (0..10) |
| 130 | .map(|r_id| { |
| 131 | Region { |
| 132 | id: r_id, |
| 133 | name: format!("Region_{}", r_id), |
| 134 | zones: (0..50) |
| 135 | .map(|z_id| { |
| 136 | Zone { |
| 137 | id: z_id, |
| 138 | terrain_data: vec![u8::try_from(r_id).expect("Overflow"); 20_000], // 20KB per zone * 50 = 1MB per region |
| 139 | } |
| 140 | }) |
| 141 | .collect(), |
| 142 | } |
| 143 | }) |
| 144 | .collect(); |
| 145 | |
| 146 | // 3. Flat Logs |
| 147 | let logs = (0..50_000) |
| 148 | .map(|i| format!("Log entry #{} with some content", i)) |
| 149 | .collect(); |
| 150 | |
| 151 | let w = WorldState { |
| 152 | id: 1, |
| 153 | name: "Azeroth_V3".into(), |
| 154 | users, |
| 155 | regions, |
| 156 | system_logs: logs, |
| 157 | }; |
| 158 | |
| 159 | println!( |
| 160 | "Done in {:.2?}. RAM Footprint: {:.2} MB", |
| 161 | start.elapsed(), |
| 162 | ALLOCATOR.peak() as f64 / 1024.0 / 1024.0 |
| 163 | ); |
| 164 | w |
| 165 | } |
| 166 | |
| 167 | // ============================================================================ |
| 168 | // 4. AUDIT EXECUTION |