common.hpp 546 B

12345678910111213141516171819
  1. #include <android/log.h>
  2. #define LOG_TAG "JNIpart"
  3. //#define LOGD(...)
  4. #define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
  5. #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
  6. #include <time.h> // clock_gettime
  7. static inline int64_t getTimeMs()
  8. {
  9. struct timespec now;
  10. clock_gettime(CLOCK_MONOTONIC, &now);
  11. return (int64_t) now.tv_sec*1000 + now.tv_nsec/1000000;
  12. }
  13. static inline int getTimeInterval(int64_t startTime)
  14. {
  15. return int(getTimeMs() - startTime);
  16. }