| 25 | // ====================== |
| 26 | |
| 27 | void generate_test_data() { |
| 28 | // Generate string JSON data |
| 29 | std::vector<std::string> strings(120'000); |
| 30 | |
| 31 | for (auto& str : strings) { |
| 32 | |
| 33 | // Create string of random letters |
| 34 | str = std::string(random::uniform(0, 120), '0'); |
| 35 | for (auto& ch : str) ch = random::uniform('a', 'z'); |
| 36 | |
| 37 | // Add some escapes at random |
| 38 | if (!str.empty() && random::uniform_double() < 0.1) { |
| 39 | const auto max_pos = static_cast<random::Uint>(str.size() - 1); |
| 40 | str.at(random::uniform_uint(0, max_pos)) = |
| 41 | random::choose({'"', '\\', '/', '\b', '\f', '\n', '\r', '\t'}); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | json::Node(strings).to_file("benchmarks/data/strings.json"); |
| 46 | |
| 47 | // Generate numeric JSON data |
| 48 | std::vector<double> numbers(180'000); |
| 49 | |
| 50 | for (auto& num : numbers) num = random::choose({random::uniform(-10., 10.), random::uniform(-1e108, 1e108)}); |
| 51 | |
| 52 | json::Node(numbers).to_file("benchmarks/data/numbers.json"); |
| 53 | } |
| 54 | |
| 55 | // ================= |
| 56 | // --- Benchmark --- |
nothing calls this directly
no test coverage detected