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

Function BM_Stat

benchmark/main.cpp:56–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54
55template <typename Json, typename PR, typename SR>
56static void BM_Stat(benchmark::State &state, std::string filename,
57 std::string_view data) {
58 Json json;
59 std::unique_ptr<const PR> pr;
60 pr = json.parse(data);
61
62 if (!pr) {
63 state.SkipWithError("Failed to parse file");
64 return;
65 }
66
67 auto sr = pr->stringfy();
68 if (!sr) {
69 state.SkipWithError("Failed to convert to string");
70 return;
71 }
72
73 auto new_pr = json.parse(sr->str());
74 if (!new_pr) {
75 state.SkipWithError("Failed to parse string");
76 return;
77 }
78
79 DocStat stat1, stat2;
80
81 bool stat_re;
82 for (auto _ : state) stat_re = pr->stat(stat1);
83
84 if (!stat_re || !new_pr->stat(stat2)) {
85 state.SkipWithError("Failed to get statistic data");
86 return;
87 }
88
89 if (stat1 != stat2) {
90 state.SkipWithError("Stat Verify failed");
91 }
92
93 state.SetLabel(filename.data());
94 state.SetBytesProcessed(int64_t(state.iterations()) * int64_t(data.size()));
95}
96
97template <typename Json, typename PR, typename SR>
98static void BM_Find(benchmark::State &state, std::string filename,

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