Profile documentation handlers. Will have list of all the profile counters and the definition of Significance added in document. Counters have the following properties: name, significance, description, unit
| 147 | // Counters have the following properties: |
| 148 | // name, significance, description, unit |
| 149 | void ProfileDocsHandler(const Webserver::WebRequest& req, Document* document) { |
| 150 | vector<const ProfileEntryPrototype*> prototypes; |
| 151 | ProfileEntryPrototypeRegistry::get()->GetPrototypes(&prototypes); |
| 152 | |
| 153 | Value profile_docs(kArrayType); |
| 154 | for (auto p : prototypes) { |
| 155 | Value p_val(kObjectType); |
| 156 | Value name(p->name(), document->GetAllocator()); |
| 157 | p_val.AddMember("name", name, document->GetAllocator()); |
| 158 | Value significance(p->significance(), document->GetAllocator()); |
| 159 | p_val.AddMember("significance", significance, document->GetAllocator()); |
| 160 | Value description(p->desc(), document->GetAllocator()); |
| 161 | p_val.AddMember("description", description, document->GetAllocator()); |
| 162 | auto unit_it = _TUnit_VALUES_TO_NAMES.find(p->unit()); |
| 163 | const char* unit_str = unit_it != _TUnit_VALUES_TO_NAMES.end() ? unit_it->second : ""; |
| 164 | Value unit(unit_str, document->GetAllocator()); |
| 165 | p_val.AddMember("unit", unit, document->GetAllocator()); |
| 166 | profile_docs.PushBack(p_val, document->GetAllocator()); |
| 167 | } |
| 168 | |
| 169 | Value significance_def(kArrayType); |
| 170 | for (auto significance : ProfileEntryPrototype::ALLSIGNIFICANCE) { |
| 171 | Value significance_obj(kObjectType); |
| 172 | Value significance_val(ProfileEntryPrototype::SignificanceString(significance), |
| 173 | document->GetAllocator()); |
| 174 | Value significance_description( |
| 175 | ProfileEntryPrototype::SignificanceDescription(significance), |
| 176 | document->GetAllocator()); |
| 177 | significance_obj.AddMember("name", significance_val,document->GetAllocator()); |
| 178 | significance_obj.AddMember("description", |
| 179 | significance_description,document->GetAllocator()); |
| 180 | significance_def.PushBack(significance_obj, document->GetAllocator()); |
| 181 | } |
| 182 | |
| 183 | document->AddMember("significance_docs", significance_def, document->GetAllocator()); |
| 184 | document->AddMember("profile_docs", profile_docs, document->GetAllocator()); |
| 185 | } |
| 186 | |
| 187 | // Registered to handle "/stacks", and produces a plain text dump of all thread stacks. |
| 188 | void StacksHandler(const Webserver::WebRequest& req, Document* document) { |
nothing calls this directly
no test coverage detected