00001 00020 #ifndef HT_SIMPLE_TEST_HELPER_H 00021 #define HT_SIMPLE_TEST_HELPER_H 00022 00023 #include <sys/time.h> 00024 00025 #define HT_MEASURE(_t_, _code_) do { \ 00026 double t0 = ht_time_d(); _code_; _t_ = ht_time_d() - t0; \ 00027 } while (0) 00028 00029 static inline double 00030 ht_time_d() { 00031 struct timeval tv; 00032 if (gettimeofday(&tv, NULL)) { 00033 perror(__FUNCTION__); 00034 } 00035 return (double)(tv.tv_sec) + (double)(tv.tv_usec) / 1e6; 00036 } 00037 00038 #define HT_CHECK(e) \ 00039 ((void)((e) ? 0 : HT_CHECK_FAIL(#e))) 00040 00041 #define HT_CHECK_FAIL(e) \ 00042 ((void)printf("%s:%u: %s: bad assertion: `%s'\n", \ 00043 __FILE__, __LINE__, __FUNCTION__, e), abort(), 0) 00044 00045 #endif /* HT_SIMPLE_TEST_HELPER_H */
1.7.2