/** * @brief Print the results of timings */ void Manager::PrintStatistics() { double fps = m_frameCount / m_timerProcessable.GetSecDouble(); LOG_INFO(m_logger, "Manager: " << m_frameCount << " frames processed in " << m_timerProcessable.GetSecDouble() * 1000 << " ms, " << fps << " fps"); // LOG_INFO("input convertion " <<m_timerConvertion<<" ms ("<<(1000.0 * m_frameCount) / m_timerConvertion<<" frames/s)"); // LOG_INFO("Total time "<< m_timerProcessable + m_timerConvertion<<" ms ("<< (1000.0 * m_frameCount) /(m_timerProcessable + m_timerConvertion)<<" frames/s)"); // Create an XML file to summarize CPU usage // if output dir is empty, write to /tmp string benchFileName = ((IsContextSet() && !GetContext().IsOutputDirEmpty()) ? GetContext().GetOutputDir() : "/tmp") + "/benchmark.xml"; ConfigFile benchSummary(benchFileName, true); ConfigReader conf = benchSummary.FindRef("benchmark", true); // Write perf to output XML ConfigReader perfModule = conf.FindRef("manager", true); perfModule.FindRef("nb_frames", true).SetValue(m_frameCount); perfModule.FindRef("timer[name=\"processable\"]", true).SetValue(m_timerProcessable.GetSecDouble()*1000); perfModule.FindRef("timer[name=\"processing\"]", true).SetValue(m_timerProcessable.GetSecDouble()*1000); // note: this line is kept for backward compatibility perfModule.FindRef("fps", true).SetValue(fps); // Call for each module for(const auto& module : m_modules) { // LOG_INFO(cpt<<": "); module->PrintStatistics(conf); } benchSummary.SaveToFile(benchFileName); }
/** * @brief Save all values and prepare xml configuration for writing */ void ParameterStructure::UpdateConfig() const { ConfigReader conf = m_configReader.Find("parameters"); for(const auto & elem : m_list) { if(m_writeAllParamsToConfig || (elem)->GetConfigurationSource() != PARAMCONF_DEF) { conf.FindRef("param[name=\"" +(elem)->GetName() + "\"]", true).SetValue((elem)->GetValueString()); } } }
/** * @brief Export current configuration to xml: this is used to create the XML and JSON files to describe each module */ void Manager::CreateEditorFiles(const string& x_fileName) { try { map<string,vector<string>> categories; Json::Value modules_json; SYSTEM("mkdir -p modules"); vector<string> moduleTypes; mr_moduleFactory.List(moduleTypes); int id = 0; for(const auto& moduleType : moduleTypes) { createEmptyConfigFile("/tmp/config_empty.xml"); ConfigFile config("/tmp/config_empty.xml"); ConfigReader moduleConfig = config.FindRef("application>module[name=\"" + moduleType + "\"]", true); moduleConfig.SetAttribute("id", id); moduleConfig.FindRef("parameters>param[name=\"class\"]", true).SetValue(moduleType); ParameterStructure* parameters = mr_parametersFactory.Create(moduleType, moduleConfig); Module* module = mr_moduleFactory.Create(moduleType, *parameters); modules_json.append(moduleType); // Append to the category categories[module->GetCategory()].push_back(moduleType); categories["all"].push_back(moduleType); // Create the specific XML string file("editor/modules/" + moduleType + ".xml"); ofstream os(file.c_str()); os<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl; module->Export(os, 0); delete module; delete parameters; os.close(); id++; } // Generate the js file containing the categories Json::Value categories_json; for(const auto& categ : categories) { for(const auto& mod : categ.second) { categories_json[categ.first].append(mod); } } ofstream of(x_fileName); of << "// This file contain the list of modules and modules categories. Generated automatically and used by the editor" << endl; of << "var availableCategories = " << categories_json << ";" << endl << endl; of << "var availableModules = " << modules_json << ";" << endl << endl; of.close(); } catch(MkException& e) { LOG_ERROR(m_logger, "Exception in Manager::Export: "<<e.what()); throw; } }