Add some support for CPU profiling
This commit is contained in:
@@ -10,13 +10,26 @@
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef WIN32
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#define stat _stat
|
||||
#endif
|
||||
|
||||
namespace util {
|
||||
|
||||
int64_t profiling_clock() {
|
||||
#ifdef WIN32
|
||||
return 0.0;
|
||||
#else
|
||||
struct timespec ts;
|
||||
assert(0 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts));
|
||||
return int64_t(ts.tv_nsec) + (int64_t(ts.tv_sec)*int64_t(1000000000));
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool ascii_isalpha(char c) {
|
||||
return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user