Add verbose define

Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
Micaela Verucchi
2020-05-15 09:41:27 +02:00
parent b5cc4ec91d
commit 360adbd1a1
3 changed files with 9 additions and 7 deletions
+1 -1
View File
@@ -131,7 +131,7 @@ int main(int argc, char *argv[]) {
std::cout<<"Min: "<<*std::min_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
std::cout<<"Max: "<<*std::max_element(detNN->stats.begin(), detNN->stats.end())/n_batch<<" ms\n";
for(int i=0; i<detNN->stats.size(); i++) mean += detNN->stats[i]; mean /= detNN->stats.size();
std::cout<<"Avg: "<<mean/n_batch<<" ms\n"<<COL_END;
std::cout<<"Avg: "<<mean/n_batch<<" ms\t"<<1000/(mean/n_batch)<<" FPS\n"<<COL_END;
return 0;
+3 -3
View File
@@ -100,7 +100,7 @@ class DetectionNN {
if(save_times && times==nullptr)
FatalError("save_times set to true, but no valid ofstream given");
printCenteredTitle(" TENSORRT detection ", '=', 30);
if(VERBOSE) printCenteredTitle(" TENSORRT detection ", '=', 30);
{
TIMER_START
for(int bi=0; bi<nBatches;++bi){
@@ -117,11 +117,11 @@ class DetectionNN {
tk::dnn::dataDim_t dim = netRT->input_dim;
dim.n = nBatches;
{
dim.print();
if(VERBOSE) dim.print();
TIMER_START
netRT->infer(dim, input_d);
TIMER_STOP
dim.print();
if(VERBOSE) dim.print();
stats.push_back(t_ns);
if(save_times) *times<<t_ns<<";";
}
+5 -3
View File
@@ -36,16 +36,18 @@
#define COL_PURPLEB "\033[1;35m"
#define COL_CYANB "\033[1;36m"
#define VERBOSE 0
// Simple Timer
#define TIMER_START timespec start, end; \
clock_gettime(CLOCK_MONOTONIC, &start);
#define TIMER_STOP_C(col) clock_gettime(CLOCK_MONOTONIC, &end); \
#define TIMER_STOP_C(col, show) clock_gettime(CLOCK_MONOTONIC, &end); \
double t_ns = ((double)(end.tv_sec - start.tv_sec) * 1.0e9 + \
(double)(end.tv_nsec - start.tv_nsec))/1.0e6; \
std::cout<<col<<"Time:"<<std::setw(16)<<t_ns<<" ms\n"<<COL_END;
if(show) std::cout<<col<<"Time:"<<std::setw(16)<<t_ns<<" ms\n"<<COL_END;
#define TIMER_STOP TIMER_STOP_C(COL_CYANB)
#define TIMER_STOP TIMER_STOP_C(COL_CYANB, VERBOSE)
/********************************************************
* Prints the error message, and exits