diff options
author | Sergei Golubchik <sergii@pisem.net> | 2010-11-25 18:17:28 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2010-11-25 18:17:28 +0100 |
commit | 65ca700def99289cc31a7040537f5aa6e12bf485 (patch) | |
tree | 97b3a07299b626c519da0e80c122b5b79b933914 /mysys/my_getsystime.c | |
parent | 2ab57de38d13d927ddff2d51aed4af34e13998f5 (diff) | |
parent | 6e5bcca7935d3c62f84bb640e5357664a210ee12 (diff) | |
download | mariadb-git-65ca700def99289cc31a7040537f5aa6e12bf485.tar.gz |
merge.
checkpoint.
does not compile.
Diffstat (limited to 'mysys/my_getsystime.c')
-rw-r--r-- | mysys/my_getsystime.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index cc5d1b83efb..60cd06b3968 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -25,6 +25,10 @@ #include "mysys_priv.h" #include "my_static.h" +#ifdef HAVE_LINUX_UNISTD_H +#include <linux/unistd.h> +#endif + ulonglong my_getsystime() { #ifdef HAVE_CLOCK_GETTIME @@ -218,3 +222,24 @@ time_t my_time_possible_from_micro(ulonglong microtime __attribute__((unused))) #endif /* defined(__WIN__) */ } + +/* + Return cpu time in milliseconds * 10 +*/ + +ulonglong my_getcputime() +{ +#ifdef HAVE_CLOCK_GETTIME + struct timespec tp; + if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tp)) + return 0; + return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100; +#elif defined(__NR_clock_gettime) + struct timespec tp; + if (syscall(__NR_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &tp)) + return 0; + return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100; +#else + return 0; +#endif /* HAVE_CLOCK_GETTIME */ +} |