Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Add TRACE_FUNC macro to record function footprints #113

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,25 @@
log->log(__VA_ARGS__); \
} \
}

#define TRACE_FUNC(...) \
{ \
auto log = diag::loggerFarm::getLogger("consoleLogger"); \
if (log != nullptr) { \
struct timespec tp; \
clock_gettime (CLOCK_REALTIME, &tp); \
std::uint64_t microsec; \
microsec = tp.tv_sec*1000000 + tp.tv_nsec/1000; \
std::string header = __FUNCTION__; \
header += "("; \
header += std::to_string(microsec); \
header += ")"; \
log->log(header); \
} \
}
#else
#define TRACE_INFO(...)
#define TRACE_FUNC(...)
#endif

#define TRACE_ERR(...) \
Expand Down
6 changes: 3 additions & 3 deletions object_analytics_node/src/visualizer/control/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

#include "control.hpp"

Control::Control() {TRACE_INFO();}
Control::Control() {TRACE_FUNC();}

Control::~Control() {TRACE_INFO();}
Control::~Control() {TRACE_FUNC();}

bool Control::Initial(View::Ptr view, stream_device::Ptr stream_device)
{
TRACE_INFO();
TRACE_FUNC();

DataView_ = view;
StreamDev_ = stream_device;
Expand Down
12 changes: 6 additions & 6 deletions object_analytics_node/src/visualizer/control/control_ds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
#include "render_lines.hpp"
#include "render_rect.hpp"

ControlDS::ControlDS() {TRACE_INFO();}
ControlDS::ControlDS() {TRACE_FUNC();}

ControlDS::~ControlDS() {TRACE_INFO();}
ControlDS::~ControlDS() {TRACE_FUNC();}

bool ControlDS::CreateContext()
{
TRACE_INFO();
TRACE_FUNC();
bool ret = false;

std::shared_ptr<sFrame> im;
Expand Down Expand Up @@ -59,20 +59,20 @@ bool ControlDS::CreateContext()

void ControlDS::StepIn()
{
TRACE_INFO();
TRACE_FUNC();
StepMode_ = true;
PauseMode_ = false;
}

void ControlDS::PlayMode()
{
TRACE_INFO();
TRACE_FUNC();
PauseMode_ = !PauseMode_;
}

void ControlDS::Run()
{
TRACE_INFO();
TRACE_FUNC();

while (!pangolin::ShouldQuit()) {
DataView_->Reset();
Expand Down
12 changes: 6 additions & 6 deletions object_analytics_node/src/visualizer/device/stream_cap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <memory>
#include <string>

stream_cap::stream_cap() {TRACE_INFO();}
stream_cap::stream_cap() {TRACE_FUNC();}

stream_cap::~stream_cap() {TRACE_INFO();}
stream_cap::~stream_cap() {TRACE_FUNC();}

bool stream_cap::init_stream(int stream_name)
{
TRACE_INFO();
TRACE_FUNC();

// stream_name_ = stream_name;
cap_ = std::make_shared<cv::VideoCapture>(stream_name);
Expand All @@ -35,7 +35,7 @@ bool stream_cap::init_stream(int stream_name)

bool stream_cap::init_stream(std::string & stream_name)
{
TRACE_INFO();
TRACE_FUNC();

// stream_name_ = stream_name;
cap_ = std::make_shared<cv::VideoCapture>(stream_name, cv::CAP_FFMPEG);
Expand All @@ -47,7 +47,7 @@ bool stream_cap::init_stream(std::string & stream_name)

bool stream_cap::reset_stream()
{
TRACE_INFO();
TRACE_FUNC();
return true;

if (cap_ != nullptr) {
Expand All @@ -63,7 +63,7 @@ bool stream_cap::reset_stream()

bool stream_cap::fetch_frame(std::shared_ptr<sFrame> & frame)
{
TRACE_INFO();
TRACE_FUNC();
bool ret = false;

if (cap_ == nullptr || !cap_->isOpened()) {
Expand Down
16 changes: 8 additions & 8 deletions object_analytics_node/src/visualizer/device/stream_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
#include "stream_ds.hpp"
#include "stream_vid.hpp"

stream_device::stream_device() {TRACE_INFO();}
stream_device::stream_device() {TRACE_FUNC();}

stream_device::~stream_device()
{
TRACE_INFO();
TRACE_FUNC();

release_stream();
}

stream_device::Ptr stream_device::create(int stream_name)
{
TRACE_INFO();
TRACE_FUNC();

stream_device::Ptr stream_dev = nullptr;

Expand All @@ -52,7 +52,7 @@ stream_device::Ptr stream_device::create(int stream_name)

stream_device::Ptr stream_device::create(std::string & stream_name)
{
TRACE_INFO();
TRACE_FUNC();

stream_device::Ptr stream_dev = nullptr;

Expand Down Expand Up @@ -85,7 +85,7 @@ stream_device::Ptr stream_device::create(std::string & stream_name)

void stream_device::release_stream()
{
TRACE_INFO();
TRACE_FUNC();

if (isAsync) {
terminate = true;
Expand All @@ -99,7 +99,7 @@ void stream_device::release_stream()

bool stream_device::process()
{
TRACE_INFO();
TRACE_FUNC();
bool ret = false;

if (initialized_ && isAsync) {
Expand Down Expand Up @@ -147,7 +147,7 @@ bool stream_device::process()

bool stream_device::read(std::shared_ptr<sFrame> & frame)
{
TRACE_INFO();
TRACE_FUNC();
if (isAsync) {
size_t count = 0;
bool res = false;
Expand All @@ -172,7 +172,7 @@ bool stream_device::read(std::shared_ptr<sFrame> & frame)

bool stream_device::query(std::shared_ptr<sFrame> & frame)
{
TRACE_INFO();
TRACE_FUNC();
if (isAsync) {
size_t count = 0;
bool res = false;
Expand Down
14 changes: 7 additions & 7 deletions object_analytics_node/src/visualizer/device/stream_ds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@
#include "common/frame_obj.hpp"
#include "common/object.hpp"

stream_ds::stream_ds() {TRACE_INFO();}
stream_ds::stream_ds() {TRACE_FUNC();}

stream_ds::~stream_ds()
{
TRACE_INFO();
TRACE_FUNC();

stream_device::release_stream();
}

bool stream_ds::init_stream(int stream_name)
{
TRACE_INFO();
TRACE_FUNC();

return false;
}

bool stream_ds::init_stream(std::string & stream_name)
{
TRACE_INFO();
TRACE_FUNC();

int slashIndex = stream_name.find_last_of('/');

Expand All @@ -58,18 +58,18 @@ bool stream_ds::init_stream(std::string & stream_name)
return false;
}

void stream_ds::release_stream() {TRACE_INFO();}
void stream_ds::release_stream() {TRACE_FUNC();}

bool stream_ds::reset_stream()
{
TRACE_INFO();
TRACE_FUNC();

return false;
}

bool stream_ds::fetch_frame(std::shared_ptr<sFrame> & frame)
{
TRACE_INFO();
TRACE_FUNC();

bool ret = false;

Expand Down
14 changes: 7 additions & 7 deletions object_analytics_node/src/visualizer/device/stream_vid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
#include <string>
#include <memory>

stream_vid::stream_vid() {TRACE_INFO();}
stream_vid::stream_vid() {TRACE_FUNC();}

stream_vid::~stream_vid() {TRACE_INFO();}
stream_vid::~stream_vid() {TRACE_FUNC();}

bool stream_vid::init_stream(int stream_name)
{
TRACE_INFO();
TRACE_FUNC();

return false; // for fake test
}

bool stream_vid::init_stream(std::string & stream_name)
{
TRACE_INFO();
TRACE_FUNC();

cap_ = std::make_shared<cv::VideoCapture>(stream_name);

Expand All @@ -43,7 +43,7 @@ bool stream_vid::init_stream(std::string & stream_name)

void stream_vid::release_stream()
{
TRACE_INFO();
TRACE_FUNC();

stream_device::release_stream();

Expand All @@ -57,7 +57,7 @@ void stream_vid::release_stream()

bool stream_vid::reset_stream()
{
TRACE_INFO();
TRACE_FUNC();

if (cap_->isOpened()) {
return cap_->set(cv::CAP_PROP_POS_FRAMES, 1);
Expand All @@ -68,7 +68,7 @@ bool stream_vid::reset_stream()

bool stream_vid::fetch_frame(std::shared_ptr<sFrame> & frame)
{
TRACE_INFO();
TRACE_FUNC();
bool ret = false;

if (cap_ == nullptr || !cap_->isOpened()) {
Expand Down
4 changes: 2 additions & 2 deletions object_analytics_node/src/visualizer/model/math_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

#include "math_model.hpp"

MathModel::MathModel() {TRACE_INFO();}
MathModel::MathModel() {TRACE_FUNC();}

MathModel::~MathModel() {TRACE_INFO();}
MathModel::~MathModel() {TRACE_FUNC();}
18 changes: 9 additions & 9 deletions object_analytics_node/src/visualizer/model/math_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include <memory>
#include <string>

MathSample::MathSample() {TRACE_INFO();}
MathSample::MathSample() {TRACE_FUNC();}

MathSample::~MathSample() {TRACE_INFO();}
MathSample::~MathSample() {TRACE_FUNC();}

bool MathSample::Initial(std::string model, std::string sampler)
{
TRACE_INFO();
TRACE_FUNC();

if (model == "Gaussian") {
MathModel_ = std::make_shared<GaussianModel>();
Expand All @@ -48,7 +48,7 @@ bool MathSample::SetMeanAndCovariance(
cv::Mat & mean, cv::Mat & covariance,
uint32_t counts)
{
TRACE_INFO();
TRACE_FUNC();
bool ret = false;

MathModel_->SetMeanAndCovariance(mean, covariance);
Expand Down Expand Up @@ -76,7 +76,7 @@ bool MathSample::SetMeanAndCovariance(

bool MathSample::GetMeanAndCovariance(cv::Mat & mean, cv::Mat & covariance)
{
TRACE_INFO();
TRACE_FUNC();

MathModel_->GetMeanAndCovariance(mean, covariance);

Expand All @@ -85,7 +85,7 @@ bool MathSample::GetMeanAndCovariance(cv::Mat & mean, cv::Mat & covariance)

bool MathSample::SetSampleCounts(uint32_t counts)
{
TRACE_INFO();
TRACE_FUNC();

Counts_ = counts;

Expand All @@ -94,14 +94,14 @@ bool MathSample::SetSampleCounts(uint32_t counts)

bool MathSample::GenSamples()
{
TRACE_INFO();
TRACE_FUNC();

return SampleModel_->GenSamples();
}

bool MathSample::FetchSamples(cv::Mat & samples)
{
TRACE_INFO();
TRACE_FUNC();

SampleModel_->FetchSamples(samples);

Expand All @@ -110,7 +110,7 @@ bool MathSample::FetchSamples(cv::Mat & samples)

cv::RotatedRect MathSample::GetCovEllipse()
{
TRACE_INFO();
TRACE_FUNC();

return MathModel_->GetCovEllipse();
}
Loading