greenplumn CAutoTimer 源码

  • 2022-08-18
  • 浏览 (270)

greenplumn CAutoTimer 代码

文件路径:/src/backend/gporca/libgpos/src/common/CAutoTimer.cpp

//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2008 - 2010 Greenplum, Inc.
//
//	@filename:
//		CAutoTimer.cpp
//
//	@doc:
//		Implementation of wrapper around wall clock timer
//---------------------------------------------------------------------------

#include "gpos/common/CAutoTimer.h"

#include "gpos/base.h"
#include "gpos/task/CAutoSuspendAbort.h"

using namespace gpos;

//---------------------------------------------------------------------------
//	@function:
//		CAutoTimer::CAutoTimer
//
//	@doc:
//		ctor
//
//---------------------------------------------------------------------------
CAutoTimer::CAutoTimer(const CHAR *sz, BOOL fPrint)
	: m_timer_text_label(sz), m_print_text_label(fPrint)
{
	GPOS_ASSERT(nullptr != sz);
}


//---------------------------------------------------------------------------
//	@function:
//		CAutoTimer::~CAutoTimer
//
//	@doc:
//		Destructor prints time difference and label
//
//---------------------------------------------------------------------------
CAutoTimer::~CAutoTimer() throw()
{
	if (m_print_text_label)
	{
		// suspend cancellation - destructors should not throw
		CAutoSuspendAbort asa;

		ULONG ulElapsedTimeMS = m_clock.ElapsedMS();

		GPOS_TRACE_FORMAT("timer:%s: %dms", m_timer_text_label,
						  ulElapsedTimeMS);
	}
}

// EOF

相关信息

greenplumn 源码目录

相关文章

greenplumn CBitSet 源码

greenplumn CBitSetIter 源码

greenplumn CBitVector 源码

greenplumn CDebugCounter 源码

greenplumn CHeapObject 源码

greenplumn CMainArgs 源码

greenplumn CRandom 源码

greenplumn CRefCount 源码

greenplumn CStackDescriptor 源码

greenplumn CStackObject 源码

0  赞