std::shared_ptr<StorageStats> WiredTigerRecoveryUnit::getOperationStatistics() const {
    std::shared_ptr<WiredTigerOperationStats> statsPtr(nullptr);

    if (!_session)
        return statsPtr;

    WT_SESSION* s = _session->getSession();
    invariant(s);

    statsPtr = std::make_shared<WiredTigerOperationStats>();
    statsPtr->fetchStats(s, "statistics:session", "statistics=(fast)");

    return statsPtr;
}
示例#2
0
//=================================================================
void	CHTimer::display(CLog *log, TSortCriterion criterion, bool displayInline /*= true*/, bool displayEx)
{
	CSimpleClock	benchClock;
	benchClock.start();
	if(!_BenchStartedOnce) // should have done at least one bench
	{
		benchClock.stop();
		_CurrNode->SonsPreambule += benchClock.getNumTicks();
		return;
	}
	log->displayNL("HTIMER: =========================================================================");
	log->displayRawNL("HTIMER: Bench cumuled results");
	typedef std::map<CHTimer *, TNodeVect> TNodeMap;
	TNodeMap nodeMap;
	TNodeVect nodeLeft;
	nodeLeft.push_back(&_RootNode);

	/// 1 ) walk the tree to build the node map (well, in a not very optimal way..)
	while (!nodeLeft.empty())
	{
		CNode *currNode = nodeLeft.back();
		nodeMap[currNode->Owner].push_back(currNode);
		nodeLeft.pop_back();
		nodeLeft.insert(nodeLeft.end(), currNode->Sons.begin(), currNode->Sons.end());
	}

	// 2 ) build statistics
	typedef std::vector<CTimerStat> TTimerStatVect;
	typedef std::vector<CTimerStat *> TTimerStatPtrVect;
	TTimerStatVect		stats(nodeMap.size());
	TTimerStatPtrVect	statsPtr(stats.size());
	//
	uint k = 0;
	for(TNodeMap::iterator it = nodeMap.begin(); it != nodeMap.end(); ++it)
	{
		statsPtr[k] = &stats[k];
		stats[k].Timer = it->first;
		stats[k].buildFromNodes(&(it->second[0]), (uint)it->second.size(), _MsPerTick);
		++k;
	}

	// 3 ) sort statistics
	if (criterion != NoSort)
	{
		CStatSorter sorter(criterion);
		std::sort(statsPtr.begin(), statsPtr.end(), sorter);
	}

	// 4 ) get root total time.
	CStats	rootStats;
	rootStats.buildFromNode( &_RootNode, _MsPerTick);

	// 5 ) display statistics
	uint maxNodeLength = 0;
	std::string format;
	if (displayInline)
	{
		for(TTimerStatPtrVect::iterator statIt = statsPtr.begin(); statIt != statsPtr.end(); ++statIt)
		{
			maxNodeLength = std::max(maxNodeLength, (uint)strlen((*statIt)->Timer->_Name));
		}
		format = "HTIMER: %-" + NLMISC::toString(maxNodeLength + 1) + "s %s";
	}
	std::string statsInline;

	log->displayRawNL(format.c_str(), "", " |      total |      local |       visits |  loc%/ glb% | sessn max |       min |       max |      mean");

	for(TTimerStatPtrVect::iterator statIt = statsPtr.begin(); statIt != statsPtr.end(); ++statIt)
	{
		if (!displayInline)
		{
			log->displayRawNL("HTIMER: =================================");
			log->displayRawNL("HTIMER: Node %s", (*statIt)->Timer->_Name);
			(*statIt)->display(log, displayEx, _WantStandardDeviation);
		}
		else
		{
			(*statIt)->getStats(statsInline, displayEx, rootStats.TotalTime, _WantStandardDeviation);
			char out[4096];
			NLMISC::smprintf(out, 2048, format.c_str(), (*statIt)->Timer->_Name, statsInline.c_str());
			log->displayRawNL(out);
		}
	}
	benchClock.stop();
	_CurrNode->SonsPreambule += benchClock.getNumTicks();
}