bool ast_debugvar_traverser_visitor::enter(class ast_declaration* node) { ShVariable* var = findShVariable(node->debug_id); assert(var); VPRINT(3, "%c%sdeclaration of %s <%i>%c%s\n", ESC_CHAR, ESC_BOLD, node->identifier, var->uniqueId, ESC_CHAR, ESC_RESET); // Add variable to the global list of all seen variables addShVariableCtx(vl, var, var->builtin, shader); if (node->initializer) { node->initializer->accept(this); exec_list* scope = &node->initializer->scope; (void)scope; /* * Actually do not add declared variable to the list here, because * Code Generation would access the data before it is declared. This should * not be needed anyway, since the data would be uninitialized * // Dont forget to check for double ids scopeList::iterator e = find(sl->begin(), sl->end(), v->getUniqueId()); // Finally at it to the list if (e == sl->end()) { sl->push_back(v->getUniqueId()); } */ } // Now add the list to the actual scope and proceed addToScope(var); dumpScope(); return false; }
bool ast_debugvar_traverser_visitor::enter(class ast_parameter_declarator* node) { // No variable when void if (node->is_void) return false; ShVariable* var = findShVariable(node->debug_id); assert(var); VPRINT(3, "%c%sparameter %s <%i> %c%s\n", ESC_CHAR, ESC_BOLD, node->identifier, var->uniqueId, ESC_CHAR, ESC_RESET); addShVariableCtx(vl, var, var->builtin, shader); addToScope(var); dumpScope(); return false; }
IReport* Registry::DumpDataJSON() { ProfileThreadsVec allThreads; { std::lock_guard<std::mutex> lock(m_ThreadsMutex); allThreads = m_ProfiledThreads; } std::function<void (indent, const unsigned long long, ProfileScope*, unsigned&, opstringstream&)> dumpScope = [&] (indent in, const unsigned long long totalTime, ProfileScope* scope, unsigned& row_id, opstringstream& output) { const auto count = scope->GetCallCount(); if(!count) return; indent_scope insc(in); output << in << "\"id\": " << row_id++ << "," << std::endl; output << in << "\"name\": \"" << scope->GetName() << "\", " << std::endl; HashMap childrenCopy = scope->Children(); unsigned long long childrenTimes = 0; if(childrenCopy.size()) { output << in << "\"children\": [ " << std::endl; { indent_scope insc(in); for(auto scopeIt = childrenCopy.begin(); scopeIt != childrenCopy.end();) { childrenTimes += (*scopeIt)->GetTime(); output << in << "{" << std::endl; dumpScope(in, totalTime, *scopeIt, row_id, output); output << in << "}" << (++scopeIt != childrenCopy.end() ? "," : "") << std::endl; } } output << in << "]," << std::endl; } const auto time = scope->GetTime(); const auto excl_time = time - childrenTimes; output << in << "\"excl_time\": " << excl_time << "," << std::endl; output << in << "\"excl_time_perc\": " << (excl_time / double(totalTime)) * 100.0 << "," << std::endl; output << in << "\"time\": " << time /* not sync */ << "," << std::endl; output << in << "\"time_perc\": " << (time / double(totalTime)) * 100.0 /* not sync */ << "," << std::endl; output << in << "\"call_count\": " << count /* not sync */ << "," << std::endl; output << in << "\"avg_call_incl\": " << time / (double)count << "," << std::endl; output << in << "\"avg_call_excl\": " << excl_time / (double)count << std::endl; }; unsigned threadId = 0; opstringstream ostream; indent in; unsigned row_id = 0; ostream << "[" << std::endl; indent_scope insc(in); unsigned long long totalTime = 0; for(auto threadIt = allThreads.cbegin(); threadIt != allThreads.cend();) { ostream << in << "{" << std::endl; totalTime = (*threadIt)->GetTime(); dumpScope(in, totalTime, *threadIt, row_id, ostream); ostream << in << "}" << (++threadIt != allThreads.cend() ? "," : "") << std::endl; } ostream << "]" << std::endl; std::unique_ptr<JSONReport, profi_deleter<JSONReport>> report(profi_new(JSONReport)); report->GetString() = ostream.str(); return report.release(); }