MCPcopy Create free account
hub / github.com/comaps/comaps / RunGraphicsBenchmark

Function RunGraphicsBenchmark

libs/map/benchmark_tools.cpp:96–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94namespace benchmark
95{
96void RunGraphicsBenchmark(Framework * framework)
97{
98#ifdef SCENARIO_ENABLE
99 using namespace df;
100
101 // Load scenario from file.
102 auto const fn = base::JoinPath(GetPlatform().SettingsDir(), "graphics_benchmark.json");
103 if (!GetPlatform().IsFileExistsByFullPath(fn))
104 return;
105
106 std::string benchmarkData;
107 try
108 {
109 ReaderPtr<Reader>(GetPlatform().GetReader(fn)).ReadAsString(benchmarkData);
110 }
111 catch (RootException const & e)
112 {
113 LOG(LCRITICAL, ("Error reading benchmark file: ", e.what()));
114 return;
115 }
116
117 std::shared_ptr<BenchmarkHandle> handle = std::make_shared<BenchmarkHandle>();
118
119 // Parse scenarios.
120 std::vector<m2::PointD> points;
121 try
122 {
123 base::Json root(benchmarkData.c_str());
124 json_t * scenariosNode = json_object_get(root.get(), "scenarios");
125 if (scenariosNode == nullptr || !json_is_array(scenariosNode))
126 return;
127 size_t const sz = json_array_size(scenariosNode);
128 handle->m_scenariosToRun.resize(sz);
129 for (size_t i = 0; i < sz; ++i)
130 {
131 auto scenarioElem = json_array_get(scenariosNode, i);
132 if (scenarioElem == nullptr)
133 return;
134 FromJSONObject(scenarioElem, "name", handle->m_scenariosToRun[i].m_name);
135 json_t * stepsNode = json_object_get(scenarioElem, "steps");
136 if (stepsNode != nullptr && json_is_array(stepsNode))
137 {
138 size_t const stepsCount = json_array_size(stepsNode);
139 auto & scenario = handle->m_scenariosToRun[i].m_scenario;
140 scenario.reserve(stepsCount);
141 for (size_t j = 0; j < stepsCount; ++j)
142 {
143 auto stepElem = json_array_get(stepsNode, j);
144 if (stepElem == nullptr)
145 return;
146 std::string actionType;
147 FromJSONObject(stepElem, "actionType", actionType);
148 if (actionType == "waitForTime")
149 {
150 json_int_t timeInSeconds = 0;
151 FromJSONObject(stepElem, "time", timeInSeconds);
152 scenario.push_back(std::unique_ptr<ScenarioManager::Action>(
153 new ScenarioManager::WaitForTimeAction(std::chrono::seconds(timeInSeconds))));

Callers 1

CreateDrapeEngineMethod · 0.85

Calls 15

JoinPathFunction · 0.85
IsExistFunction · 0.85
RunScenarioFunction · 0.85
GetRegionCountryIdMethod · 0.80
GetNodeStatusesMethod · 0.80
DownloadNodeMethod · 0.80
getMethod · 0.65
FromJSONObjectFunction · 0.50
FromLatLonFunction · 0.50
ReadAsStringMethod · 0.45
GetReaderMethod · 0.45

Tested by

no test coverage detected