MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / writeJSON

Function writeJSON

src/openrct2/profiling/Profiling.cpp:226–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224 }
225
226 bool writeJSON(const std::string& filePath)
227 {
228 std::scoped_lock lock(Detail::getRegistryMutex());
229 const auto& registry = Detail::getRegistry();
230
231 json_t functions = json_t::array();
232
233 for (size_t i = 0; i < registry.size(); ++i)
234 {
235 const auto* func = registry[i];
236
237 json_t parentIndices = json_t::array();
238 for (const auto* parent : func->getParents())
239 {
240 auto it = std::find(registry.begin(), registry.end(), parent);
241 if (it != registry.end())
242 parentIndices.push_back(std::distance(registry.begin(), it));
243 }
244
245 json_t childIndices = json_t::array();
246 for (const auto* child : func->getChildren())
247 {
248 auto it = std::find(registry.begin(), registry.end(), child);
249 if (it != registry.end())
250 childIndices.push_back(std::distance(registry.begin(), it));
251 }
252
253 functions.push_back(
254 {
255 { "name", func->getName() },
256 { "callCount", func->getCallCount() },
257 { "minTime", func->getMinTime() },
258 { "maxTime", func->getMaxTime() },
259 { "avgTime", func->getAverageTime() },
260 { "totalTime", func->getTotalTime() },
261 { "parents", parentIndices },
262 { "children", childIndices },
263 });
264 }
265
266 json_t root = { { "functions", functions } };
267
268 try
269 {
270 Json::WriteToFile(filePath, root);
271 return true;
272 }
273 catch (...)
274 {
275 return false;
276 }
277 }
278
279 bool hasExtension(const std::string& path, const std::string& ext)
280 {

Callers 1

exportDataFunction · 0.85

Calls 13

getParentsMethod · 0.80
getChildrenMethod · 0.80
getCallCountMethod · 0.80
getMinTimeMethod · 0.80
getMaxTimeMethod · 0.80
getAverageTimeMethod · 0.80
endMethod · 0.65
WriteToFileFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected