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

Function BM_Find

benchmark/main.cpp:98–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97template <typename Json, typename PR, typename SR>
98static 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
138template <typename Json, typename PR, typename SR>
139static void BM_Decode(benchmark::State &state, std::string filename,

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected