| 96 | |
| 97 | template <typename Json, typename PR, typename SR> |
| 98 | static void BM_Find(benchmark::State &state, std::string filename, |
| 99 | std::string_view data) { |
| 100 | Json json; |
| 101 | std::unique_ptr<const PR> pr; |
| 102 | pr = json.parse(data); |
| 103 | |
| 104 | if (!pr) { |
| 105 | state.SkipWithError("Failed to parse file"); |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | auto sr = pr->stringfy(); |
| 110 | if (!sr) { |
| 111 | state.SkipWithError("Failed to convert to string"); |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | auto new_pr = json.parse(sr->str()); |
| 116 | if (!new_pr) { |
| 117 | state.SkipWithError("Failed to parse string"); |
| 118 | return; |
| 119 | } |
| 120 | |
| 121 | DocStat stat1, stat2; |
| 122 | if (!pr->stat(stat1) || !new_pr->stat(stat2)) { |
| 123 | state.SkipWithError("Failed to get statistic data"); |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | if (stat1 != stat2) { |
| 128 | state.SkipWithError("Stat Verify failed"); |
| 129 | } |
| 130 | |
| 131 | DocStat stat3; |
| 132 | for (auto _ : state) pr->find(stat3); |
| 133 | |
| 134 | state.SetLabel(filename.data()); |
| 135 | state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(data.size())); |
| 136 | } |
| 137 | |
| 138 | template <typename Json, typename PR, typename SR> |
| 139 | static void BM_Decode(benchmark::State &state, std::string filename, |