| 171 | } |
| 172 | |
| 173 | bool run_large_benchmark() { |
| 174 | bool success = true; |
| 175 | |
| 176 | // Load large JSON file |
| 177 | fl::string large_json; |
| 178 | const char* filepath = "tests/profile/benchmark_1mb.json"; |
| 179 | |
| 180 | printf("\nLoading large JSON file: %s\n", filepath); |
| 181 | |
| 182 | // Initialize FileSystem for testing |
| 183 | FileSystem fs; |
| 184 | FsImplPtr fsImpl = make_sdcard_filesystem(0); |
| 185 | if (!fs.begin(fsImpl)) { |
| 186 | printf("❌ ERROR: Failed to initialize test filesystem\n"); |
| 187 | return false; |
| 188 | } |
| 189 | |
| 190 | // Open and read the JSON file |
| 191 | ifstream fh = fs.openRead(filepath); |
| 192 | if (!fh.is_open()) { |
| 193 | printf("❌ ERROR: Could not open %s\n", filepath); |
| 194 | printf(" Make sure to download it first with:\n"); |
| 195 | printf(" curl -o %s https://microsoftedge.github.io/Demos/json-dummy-data/1MB.json\n", filepath); |
| 196 | return false; |
| 197 | } |
| 198 | |
| 199 | size_t file_size = fh.size(); |
| 200 | large_json.resize(file_size); |
| 201 | size_t bytes_read = fh.read(reinterpret_cast<u8*>(&large_json[0]), file_size); |
| 202 | fh.close(); |
| 203 | |
| 204 | if (bytes_read != file_size) { |
| 205 | printf("❌ ERROR: Read %zu bytes but expected %zu bytes\n", bytes_read, file_size); |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | printf("✓ Loaded %zu bytes (%.2f KB)\n", bytes_read, bytes_read / 1024.0); |
| 210 | |
| 211 | // Run benchmark with fewer iterations for large file |
| 212 | run_benchmark("LARGE JSON BENCHMARK (1MB Real-World Data)", large_json, 100, success); |
| 213 | |
| 214 | return success; |
| 215 | } |
| 216 | |
| 217 | void print_usage() { |
| 218 | printf("JSON Performance Profiler\n"); |