bool MeasureMetric::runOnFunction(Function &F) { for (Function::iterator b = F.begin(), be = F.end(); b != be; b++) { for (BasicBlock::iterator i = b->begin(), ie = b->end(); i != ie; i++) { Instruction *inst = i; if (dyn_cast<CastInst>(inst)) { castInstCount++; } else if (FCmpInst* target = dyn_cast<FCmpInst>(inst)) { Value *val1 = target->getOperand(0); increaseCounter(val1->getType(), cmpOp); } else if (BinaryOperator *target = dyn_cast<BinaryOperator>(inst)) { Value *val1 = target->getOperand(0); increaseCounter(val1->getType(), arithOp); } else if (LoadInst *target = dyn_cast<LoadInst>(inst)) { Value *val1 = target->getPointerOperand(); PointerType* pointerType = (PointerType*) val1->getType(); increaseCounter(pointerType->getElementType(), loadOp); } else if (StoreInst* target = dyn_cast<StoreInst>(inst)) { Value *val1 = target->getOperand(0); increaseCounter(val1->getType(), storeOp); } } } return false; }
//============================================================================== void CountersManager::stopTimerIncreaseCounter(Counter counter) { // The counter should be F64 ANKI_ASSERT(cinfo[(U)counter].m_flags & CF_F64); // The timer should have started ANKI_ASSERT(m_counterTimes[(U)counter] > 0.0); F32 prevTime = m_counterTimes[(U)counter]; m_counterTimes[(U)counter] = 0.0; increaseCounter(counter, HighRezTimer::getCurrentTime() - prevTime); }
void ConfigManager::init (IBindingSpaceListener *bindingSpaceListener, int argc, char **argv) { _persister = new ConfigPersisterSQL(System.getDatabaseDirectory() + Singleton<Application>::getInstance().getName() + ".sqlite"); Log::info(LOG_COMMON, "init configmanager"); _persister->init(); _bindingSpaceListener = bindingSpaceListener; LUA lua; Log::info(LOG_COMMON, "load config lua file"); const bool success = lua.load("config.lua"); if (!success) { Log::error(LOG_COMMON, "could not load config"); } if (success) { Log::info(LOG_COMMON, "load config values"); getKeyValueMap(lua, _configVarMap, "settings"); Log::info(LOG_COMMON, "load keybindings"); getBindingMap(lua, _keybindings, KEY_CONFIG_KEYBINDINGS, KEYBOARD); Log::info(LOG_COMMON, "load controller bindings"); getBindingMap(lua, _controllerBindings, KEY_CONFIG_CONTROLLERBINDINGS, CONTROLLER); } _language = getConfigValue(_configVarMap, "language", System.getLanguage()); _gameController = getConfigValue(_configVarMap, "gamecontroller"); _gameControllerTriggerAxis = getConfigValue(_configVarMap, "gamecontrollertriggeraxis"); _showFPS = getConfigValue(_configVarMap, "showfps"); _width = getConfigValue(_configVarMap, "width", "-1"); _height = getConfigValue(_configVarMap, "height", "-1"); _fullscreen = getConfigValue(_configVarMap, "fullscreen", "true"); _soundEnabled = getConfigValue(_configVarMap, "sound"); _port = getConfigValue(_configVarMap, "port", "4567"); _debug = getConfigValue(_configVarMap, "debug", "false"); #ifdef NONETWORK _network = getConfigValue(_configVarMap, "network", "false"); #else _network = getConfigValue(_configVarMap, "network", "true"); #endif _vsync = getConfigValue(_configVarMap, "vsync", "true"); _textureSize = getConfigValue(_configVarMap, "texturesize", "auto"); _grabMouse = getConfigValue(_configVarMap, "grabmouse", "true"); _soundEngine = getConfigValue(_configVarMap, "soundengine", "sdl"); _particles = getConfigValue(_configVarMap, "particles", "0"); _renderToTexture = getConfigValue(_configVarMap, "rendertotexture", "1"); getConfigValue(_configVarMap, "red", "8"); getConfigValue(_configVarMap, "green", "8"); getConfigValue(_configVarMap, "blue", "8"); _serverName = getConfigVar("servername", System.getCurrentUser()); _name = getConfigVar("name", System.getCurrentUser()); _debugui = getConfigVar("debugui", "false"); _debugEntity = getConfigVar("debugentity", "false", true); getConfigVar("alreadyrated", "false", true); _mode = getConfigValue(_configVarMap, "mode", ""); #if 0 // disabled because the vars must be created on access - to set the flags properly for (KeyValueMap::iterator i = _configVarMap.begin(); i != _configVarMap.end(); ++i) { getConfigVar(i->first, i->second, true); } std::vector<std::string> vars; _persister->getVars(vars); for (std::vector<std::string>::const_iterator i = vars.begin(); i != vars.end(); ++i) { getConfigVar(*i); } for (auto entry : _configVars) { Log::info(LOG_COMMON, "'%s' with value '%s'", entry.first.c_str(), entry.second->getValue().c_str()); } #endif memset(&_debugRendererData, 0, sizeof(_debugRendererData)); Log::info(LOG_COMMON, "mouse grab enabled: %s", _grabMouse->getValue().c_str()); Log::info(LOG_COMMON, "controller enabled: %s", _gameController->getValue().c_str()); Log::info(LOG_COMMON, " sound enabled: %s", _soundEnabled->getValue().c_str()); Log::info(LOG_COMMON, " debug enabled: %s", _debug->getValue().c_str()); Commands.registerCommand("loglevel", bindFunction(ConfigManager::setLogLevel)); CommandPtr cmd = Commands.registerCommand(CMD_SETVAR, bindFunction(ConfigManager::setConfig)); cmd->setCompleter([&] (const std::string& input, std::vector<std::string>& matches) { for (auto entry : _configVars) { if (!string::startsWith(entry.first, input)) continue; matches.push_back(entry.first); } }); Commands.registerCommand(CMD_LISTVARS, bindFunction(ConfigManager::listConfigVariables)); for (int i = 0; i < argc; i++) { if (argv[i][0] != '-') continue; const std::string command = &argv[i][1]; if (command == CMD_SETVAR) { if (i + 2 >= argc) continue; const std::string var = argv[i + 1]; const std::string val = argv[i + 2]; ConfigVarPtr p = getConfigVar(var); p->setValue(val); *argv[i] = *argv[i + 1] = *argv[i + 2] = '\0'; i += 2; } else if (command == "loglevel") { if (i + 1 >= argc) continue; ICommand::Args a; a.push_back(argv[i + 1]); setLogLevel(a); *argv[i] = *argv[i + 1] = '\0'; i += 1; } } increaseCounter("launchcount"); _persister->save(_configVars); }