MCPcopy Create free account
hub / github.com/bytedance/sonic-cpp / BM_Decode

Function BM_Decode

benchmark/main.cpp:139–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137
138template <typename Json, typename PR, typename SR>
139static void BM_Decode(benchmark::State &state, std::string filename,
140 std::string_view data) {
141 Json json;
142 std::unique_ptr<const PR> pr;
143 for (auto _ : state) pr = json.parse(data);
144
145 if (!pr) {
146 state.SkipWithError("Failed to parse file");
147 return;
148 }
149
150 auto sr = pr->stringfy();
151 if (!sr) {
152 state.SkipWithError("Failed to convert to string");
153 return;
154 }
155
156 auto new_pr = json.parse(sr->str());
157 if (!new_pr) {
158 state.SkipWithError("Failed to parse string");
159 return;
160 }
161
162 DocStat stat1, stat2;
163 if (!pr->stat(stat1) || !new_pr->stat(stat2)) {
164 state.SkipWithError("Failed to get statistic data");
165 return;
166 }
167
168 if (stat1 != stat2) {
169 state.SkipWithError("Stat Verify failed");
170 }
171
172 state.SetLabel(filename.data());
173 state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(data.size()));
174}
175
176static void regitser_OnDemand() {
177 std::vector<OnDemand> tests = {

Callers

nothing calls this directly

Calls 4

parseMethod · 0.80
stringfyMethod · 0.80
strMethod · 0.80
statMethod · 0.80

Tested by

no test coverage detected