Disable buffer pool timestamps

master
Ismael Gomez 7 years ago
parent 5f0bd0e74b
commit 206e41a244

@ -96,6 +96,8 @@ static const char error_text[ERROR_N_ITEMS][20] = { "None",
"Can't start", "Can't start",
"Already started"}; "Already started"};
//#define ENABLE_TIMESTAMP
/****************************************************************************** /******************************************************************************
* Byte and Bit buffers * Byte and Bit buffers
* *
@ -147,33 +149,27 @@ public:
} }
long get_latency_us() long get_latency_us()
{ {
#ifdef ENABLE_TIMESTAMP
if(!timestamp_is_set) if(!timestamp_is_set)
return 0; return 0;
gettimeofday(&timestamp[2], NULL); gettimeofday(&timestamp[2], NULL);
get_time_interval(timestamp); get_time_interval(timestamp);
return timestamp[0].tv_usec; return timestamp[0].tv_usec;
#else
return 0;
#endif
} }
void set_timestamp() void set_timestamp()
{ {
#ifdef ENABLE_TIMESTAMP
gettimeofday(&timestamp[1], NULL); gettimeofday(&timestamp[1], NULL);
timestamp_is_set = true; timestamp_is_set = true;
#endif
} }
private: private:
void get_time_interval(struct timeval * tdata) {
tdata[0].tv_sec = tdata[2].tv_sec - tdata[1].tv_sec;
tdata[0].tv_usec = tdata[2].tv_usec - tdata[1].tv_usec;
if (tdata[0].tv_usec < 0) {
tdata[0].tv_sec--;
tdata[0].tv_usec += 1000000;
}
}
struct timeval timestamp[3]; struct timeval timestamp[3];
bool timestamp_is_set; bool timestamp_is_set;
byte_buffer_t *next; byte_buffer_t *next;
@ -215,15 +211,21 @@ struct bit_buffer_t{
} }
long get_latency_us() long get_latency_us()
{ {
#ifdef ENABLE_TIMESTAMP
if(!timestamp_is_set) if(!timestamp_is_set)
return 0; return 0;
gettimeofday(&timestamp[2], NULL); gettimeofday(&timestamp[2], NULL);
return timestamp[0].tv_usec; return timestamp[0].tv_usec;
#else
return 0;
#endif
} }
void set_timestamp() void set_timestamp()
{ {
#ifdef ENABLE_TIMESTAMP
gettimeofday(&timestamp[1], NULL); gettimeofday(&timestamp[1], NULL);
timestamp_is_set = true; timestamp_is_set = true;
#endif
} }
private: private:

Loading…
Cancel
Save