2016-09-06 22:15:50 +03:00
|
|
|
/************************************************************************
|
|
|
|
* file name : block.cpp
|
|
|
|
* ----------------- :
|
|
|
|
* creation time : 2016/02/16
|
|
|
|
* authors : Sergey Yagovtsev, Victor Zarubkin
|
|
|
|
* emails : yse.sey@gmail.com, v.s.zarubkin@gmail.com
|
|
|
|
* ----------------- :
|
|
|
|
* description : The file contains implementation of profiling blocks
|
|
|
|
* :
|
|
|
|
* license : Lightweight profiler library for c++
|
|
|
|
* : Copyright(C) 2016 Sergey Yagovtsev, Victor Zarubkin
|
|
|
|
* :
|
|
|
|
* : This program is free software : you can redistribute it and / or modify
|
|
|
|
* : it under the terms of the GNU General Public License as published by
|
|
|
|
* : the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* : (at your option) any later version.
|
|
|
|
* :
|
|
|
|
* : This program is distributed in the hope that it will be useful,
|
|
|
|
* : but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
|
|
|
* : GNU General Public License for more details.
|
|
|
|
* :
|
|
|
|
* : You should have received a copy of the GNU General Public License
|
|
|
|
* : along with this program.If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
************************************************************************/
|
2016-09-20 22:57:34 +03:00
|
|
|
|
2016-06-20 23:21:54 +03:00
|
|
|
#include "profile_manager.h"
|
2016-02-16 23:21:12 +03:00
|
|
|
|
|
|
|
using namespace profiler;
|
|
|
|
|
2016-08-28 02:41:02 +03:00
|
|
|
BaseBlockData::BaseBlockData(timestamp_t _begin_time, block_id_t _descriptor_id)
|
|
|
|
: m_begin(_begin_time)
|
|
|
|
, m_end(0)
|
|
|
|
, m_id(_descriptor_id)
|
2016-02-16 23:21:12 +03:00
|
|
|
{
|
2016-08-28 02:41:02 +03:00
|
|
|
|
2016-02-16 23:21:12 +03:00
|
|
|
}
|
|
|
|
|
2016-09-04 14:48:35 +03:00
|
|
|
Block::Block(Block&& that)
|
|
|
|
: BaseBlockData(that.m_begin, that.m_id)
|
|
|
|
, m_name(that.m_name)
|
2016-09-20 22:57:34 +03:00
|
|
|
, m_status(that.m_status)
|
2016-09-04 14:48:35 +03:00
|
|
|
{
|
|
|
|
m_end = that.m_end;
|
|
|
|
}
|
|
|
|
|
2016-09-22 23:06:43 +03:00
|
|
|
Block::Block(const BaseBlockDescriptor* _descriptor, const char* _runtimeName)
|
|
|
|
: BaseBlockData(1ULL, _descriptor->id())
|
2016-09-11 16:57:35 +03:00
|
|
|
, m_name(_runtimeName)
|
2016-09-22 23:06:43 +03:00
|
|
|
, m_status(_descriptor->status())
|
2016-09-04 14:48:35 +03:00
|
|
|
{
|
2016-09-20 22:57:34 +03:00
|
|
|
|
2016-09-04 14:48:35 +03:00
|
|
|
}
|
|
|
|
|
2016-09-11 16:57:35 +03:00
|
|
|
Block::Block(timestamp_t _begin_time, block_id_t _descriptor_id, const char* _runtimeName)
|
2016-09-04 14:48:35 +03:00
|
|
|
: BaseBlockData(_begin_time, _descriptor_id)
|
2016-09-09 00:09:47 +03:00
|
|
|
, m_name(_runtimeName)
|
2016-09-20 22:57:34 +03:00
|
|
|
, m_status(::profiler::ON)
|
2016-09-11 16:57:35 +03:00
|
|
|
{
|
2016-09-20 22:57:34 +03:00
|
|
|
|
2016-09-11 16:57:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Block::start()
|
|
|
|
{
|
|
|
|
m_begin = getCurrentTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Block::start(timestamp_t _time)
|
2016-08-28 02:41:02 +03:00
|
|
|
{
|
2016-09-11 16:57:35 +03:00
|
|
|
m_begin = _time;
|
2016-08-28 02:41:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Block::finish()
|
2016-02-16 23:21:12 +03:00
|
|
|
{
|
2016-08-28 02:41:02 +03:00
|
|
|
m_end = getCurrentTime();
|
|
|
|
}
|
2016-02-20 05:24:12 +03:00
|
|
|
|
2016-09-11 16:57:35 +03:00
|
|
|
void Block::finish(timestamp_t _time)
|
2016-09-04 14:48:35 +03:00
|
|
|
{
|
2016-09-11 16:57:35 +03:00
|
|
|
m_end = _time;
|
2016-09-04 14:48:35 +03:00
|
|
|
}
|
|
|
|
|
2016-08-28 02:41:02 +03:00
|
|
|
Block::~Block()
|
|
|
|
{
|
2016-09-09 00:09:47 +03:00
|
|
|
if (!finished())
|
2016-08-28 02:41:02 +03:00
|
|
|
::profiler::endBlock();
|
2016-02-16 23:25:12 +03:00
|
|
|
}
|