void print_output() { g_context->write( "<link rel='stylesheet' href='/css/hotprofiler.css' type='text/css'>" "<script language='javascript' src='/js/hotprofiler.js'></script>" "<p><center><h2>Hotprofiler Data</h2></center><br>" "<div id='hotprofiler_stats'></div>" "<script language='javascript'>hotprofiler_data = ["); for (StatsMap::const_iterator iter = m_stats.begin(); iter != m_stats.end(); ++iter) { g_context->write("{\"fn\": \""); g_context->write(iter->first.c_str()); g_context->write("\""); const CountMap &counts = iter->second; char buf[512]; snprintf( buf, sizeof(buf), ",\"ct\": %" PRId64 ",\"wt\": %" PRId64 ",\"ut\": %" PRId64 ",\"st\": 0", counts.count, (int64_t)to_usec(counts.tsc, m_MHz), (int64_t)to_usec(counts.vtsc, m_MHz, true)); g_context->write(buf); g_context->write("},\n"); } g_context->write("]; write_data('ut', false);</script><br><br> <br>"); }
// write statistics of test run to file void Responder::write_statistics_to_file(StatsMap mapStats) { try { ofstream results(_stats_filename.c_str()); for (StatsMap::iterator it = mapStats.begin(); it != mapStats.end(); ++it) { STATS& stats = it->second; double d = 0.0; if (stats.detected > 0) d = 1.0 - ((double)stats.missed / (double)stats.detected); cout << "\t" << setprecision(6) << stats.delay << "\t\t" << setprecision(6) << d << endl; results << (stats.delay * _opt.time_mul) << " " << setprecision(6) << d << endl; } cout << "Statistics written to: " << _stats_filename << endl; } catch (...) { cout << "Failed to write statistics to: " << _stats_filename << endl; } }
static bool extractStats(phpret& ret, StatsMap& stats, int flags, int64 MHz) { for (typename StatsMap::const_iterator iter = stats.begin(); iter != stats.end(); ++iter) { returnVals(ret, iter->first, iter->second, flags, MHz); } return true; }
// make sure write files is intended void Responder::safe_write_statistics_to_file(StatsMap mapStats, uint64_t max_success, int return_code) { if ((_opt.test_iterations > 0) && (_stats_filename.empty() == false) && (_opt.no_stats_file == false)) { if (mapStats.empty()) { cout << "No results to output (not writing statistics file)" << endl; } else if ((max_success == 0) && (return_code == RETCODE_MANUAL_ABORT)) { cout << "Aborted before a single successful timed burst (not writing statistics file)" << endl; } else { write_statistics_to_file(mapStats); } write_log_file(); } }
Status ViewGraph::insertAndValidate(const ViewDefinition& view, const std::vector<NamespaceString>& refs, int pipelineSize) { insertWithoutValidating(view, refs, pipelineSize); // Perform validation on this newly inserted view. Note, if the graph was put in an invalid // state through unvalidated inserts (e.g. if the user manually edits system.views) // this may not necessarily be detected. We only check for errors introduced by this view. const auto& viewNss = view.name(); uint64_t nodeId = _getNodeId(viewNss); // If the graph fails validation for any reason, the insert is automatically rolled back on // exiting this method. auto rollBackInsert = [&]() -> auto { remove(viewNss); }; auto guard = MakeGuard(rollBackInsert); // Check for cycles and get the height of the children. StatsMap statsMap; std::vector<uint64_t> cycleVertices; cycleVertices.reserve(kMaxViewDepth); auto childRes = _validateChildren(nodeId, nodeId, 0, &statsMap, &cycleVertices); if (!childRes.isOK()) { return childRes; } // Subtract one since the child height includes the non-view leaf node(s). int childrenHeight = statsMap[nodeId].height - 1; int childrenSize = statsMap[nodeId].cumulativeSize; // Get the height of the parents to obtain the diameter through this node, as well as the size // of the pipeline to check if if the combined pipeline exceeds the max size. statsMap.clear(); auto parentRes = _validateParents(nodeId, 0, &statsMap); if (!parentRes.isOK()) { return parentRes; } // Check the combined heights of the children and parents. int parentsHeight = statsMap[nodeId].height; // Subtract one since the parent and children heights include the current node. int diameter = parentsHeight + childrenHeight - 1; if (diameter > kMaxViewDepth) { return {ErrorCodes::ViewDepthLimitExceeded, str::stream() << "View depth limit exceeded; maximum depth is " << kMaxViewDepth}; } // Check the combined sizes of the children and parents. int parentsSize = statsMap[nodeId].cumulativeSize; // Subtract the current node's size since the parent and children sizes include the current // node. const Node& currentNode = _graph[nodeId]; int pipelineTotalSize = parentsSize + childrenSize - currentNode.size; if (pipelineTotalSize > kMaxViewPipelineSizeBytes) { return {ErrorCodes::ViewPipelineMaxSizeExceeded, str::stream() << "Operation would result in a resolved view pipeline that exceeds " "the maximum size of " << kMaxViewPipelineSizeBytes << " bytes"}; } guard.Dismiss(); return Status::OK(); }