Commit 6860eec8 authored by Davis King's avatar Davis King

Changed the names of the variables in the TIME_THIS macro to avoid

any likely name collisions with user's code.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403105
parent c29b9fd6
...@@ -16,28 +16,28 @@ ...@@ -16,28 +16,28 @@
#include <iostream> #include <iostream>
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
#define TIME_THIS_TO(op,out) \ #define TIME_THIS_TO(_tt_op,_tt_out) \
{ \ { \
clock_t start, end; \ clock_t _tt_start, _tt_end; \
tms timesbuf; \ tms _tt_timesbuf; \
start = times(&timesbuf); \ _tt_start = times(&_tt_timesbuf); \
op; \ _tt_op; \
end = times(&timesbuf); \ _tt_end = times(&_tt_timesbuf); \
long ticks = sysconf(_SC_CLK_TCK); \ long _tt_ticks = sysconf(_SC_CLK_TCK); \
if ((double)(end-start)/(double)ticks < 1) \ if ((double)(_tt_end-_tt_start)/(double)_tt_ticks < 1) \
{ \ { \
out << "\ntime: " \ _tt_out << "\ntime: " \
<< (int)(1000*((double)(end-start)/(double)ticks)) << "ms\n"; \ << (int)(1000*((double)(_tt_end-_tt_start)/(double)_tt_ticks)) << "ms\n"; \
} \ } \
else \ else \
{ \ { \
out << "\ntime: " \ _tt_out << "\ntime: " \
<< (double)(end-start)/(double)ticks << "sec\n"; \ << (double)(_tt_end-_tt_start)/(double)_tt_ticks << "sec\n"; \
} \ } \
} \ } \
#define TIME_THIS(op) TIME_THIS_TO(op,std::cout) #define TIME_THIS(_tt_op) TIME_THIS_TO(_tt_op,std::cout)
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -52,25 +52,26 @@ ...@@ -52,25 +52,26 @@
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
#define TIME_THIS_TO(op,out) \ #define TIME_THIS_TO(_tt_op,_tt_out) \
{ \ { \
unsigned long count = GetTickCount(); \ unsigned long _tt_count = GetTickCount(); \
op; \ _tt_op; \
count = GetTickCount() - count; \ _tt_count = GetTickCount() - _tt_count; \
if (count < 1000) \ if (_tt_count < 1000) \
{ \ { \
out << "\ntime: " << count << "ms\n"; \ _tt_out << "\ntime: " << _tt_count << "ms\n"; \
} \ } \
else \ else \
{ \ { \
out << "\ntime: " << static_cast<double>(count)/1000 << "sec\n"; \ _tt_out << "\ntime: " << static_cast<double>(_tt_count)/1000 << "sec\n"; \
} \ } \
} \ } \
#define TIME_THIS(op) TIME_THIS_TO(op,std::cout) #define TIME_THIS(_tt_op) TIME_THIS_TO(_tt_op,std::cout)
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
#endif #endif
#endif // DLIB_TIME_THIs_ #endif // DLIB_TIME_THIs_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment