| 132 | } |
| 133 | |
| 134 | bool run_large_benchmark() { |
| 135 | bool success = true; |
| 136 | |
| 137 | printf("\nLoading large JSON file: tests/profile/benchmark_1mb.json\n"); |
| 138 | |
| 139 | // Initialize FileSystem for testing |
| 140 | FileSystem fs; |
| 141 | FsImplPtr fsImpl = make_sdcard_filesystem(0); |
| 142 | if (!fs.begin(fsImpl)) { |
| 143 | printf("❌ ERROR: Failed to initialize test filesystem\n"); |
| 144 | return false; |
| 145 | } |
| 146 | |
| 147 | // Open and read the JSON file |
| 148 | ifstream fh = fs.openRead("tests/profile/benchmark_1mb.json"); |
| 149 | if (!fh.is_open()) { |
| 150 | printf("❌ ERROR: Could not open tests/profile/benchmark_1mb.json\n"); |
| 151 | printf(" Download it with: curl -o tests/profile/benchmark_1mb.json https://microsoftedge.github.io/Demos/json-dummy-data/1MB.json\n"); |
| 152 | return false; |
| 153 | } |
| 154 | |
| 155 | // Read file contents |
| 156 | fl::size file_size = fh.size(); |
| 157 | fl::string large_json; |
| 158 | large_json.resize(file_size); |
| 159 | fl::size bytes_read = fh.read(reinterpret_cast<u8*>(&large_json[0]), file_size); |
| 160 | fh.close(); |
| 161 | |
| 162 | if (bytes_read != file_size) { |
| 163 | printf("❌ ERROR: Read %zu bytes but expected %zu bytes\n", bytes_read, file_size); |
| 164 | return false; |
| 165 | } |
| 166 | |
| 167 | printf("✓ Loaded %zu bytes (%.2f KB)\n", bytes_read, bytes_read / 1024.0); |
| 168 | |
| 169 | run_benchmark("TEST 2: LARGE JSON (1MB Real-World Data)", large_json, 50, success); |
| 170 | return success; |
| 171 | } |
| 172 | |
| 173 | void print_usage() { |
| 174 | printf("JSON Parser A/B Benchmark\n"); |