CHECK_SYMBOL_EXISTS(dirfd "sys/types.h;unistd.h;dirent.h" HAVE_DIRFD)
CHECK_SYMBOL_EXISTS(fpathconf "sys/types.h;unistd.h" HAVE_FPATHCONF)
CHECK_SYMBOL_EXISTS(sigaltstack "signal.h" HAVE_SIGALTSTACK)
+CHECK_SYMBOL_EXISTS(clock_getcpuclockid "sys/types.h;time.h" HAVE_CLOCK_GETCPUCLOCKID)
+CHECK_SYMBOL_EXISTS(RUSAGE_SELF "sys/types.h;sys/resource.h" HAVE_RUSAGE_SELF)
IF(ENABLE_PCRE2 MATCHES "ON")
IF(HAVE_PCRE_JIT)
#cmakedefine HAVE_ARPA_INET_H 1
#cmakedefine HAVE_ASM_PAUSE 1
#cmakedefine HAVE_ATOMIC_BUILTINS 1
+#cmakedefine HAVE_CLOCK_GETCPUCLOCKID 1
#cmakedefine HAVE_CLOCK_GETTIME 1
#cmakedefine HAVE_CLOCK_PROCESS_CPUTIME_ID 1
#cmakedefine HAVE_CLOCK_VIRTUAL 1
#cmakedefine HAVE_PWD_H 1
#cmakedefine HAVE_RDTSC 1
#cmakedefine HAVE_READPASSPHRASE_H 1
+#cmakedefine HAVE_RUSAGE_SELF 1
#cmakedefine HAVE_SA_SIGINFO 1
#cmakedefine HAVE_SANE_SHMEM 1
#cmakedefine HAVE_SANE_TZSET 1
GByteArray *part_content;
rspamd_ftok_t charset_tok;
struct rspamd_mime_part *part = text_part->mime_part;
+ gdouble t1, t2;
+ t1 = rspamd_get_ticks (TRUE);
if (rspamd_str_has_8bit (text_part->raw.begin, text_part->raw.len)) {
text_part->flags |= RSPAMD_MIME_TEXT_PART_FLAG_8BIT;
}
rspamd_mime_text_part_ucs_from_utf (task, text_part);
rspamd_mime_text_part_normalise (task, text_part);
rspamd_mime_text_part_maybe_renormalise (task, text_part);
+ t2 = rspamd_get_ticks (TRUE);
+ msg_err_task ("conversion time: %.0f ticks", t2 - t1);
return;
}
}
SET_PART_UTF (text_part);
+ t2 = rspamd_get_ticks (TRUE);
+ msg_err_task ("conversion time: %.0f ticks", t2 - t1);
}
#include <x86intrin.h>
#endif
#endif
+
#include <math.h> /* for pow */
#include <glob.h> /* in fact, we require this file ultimately */
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
+ static clockid_t cid = -1;
+ if (cid == -1) {
+# ifdef HAVE_CLOCK_GETCPUCLOCKID
+ if (clock_getcpuclockid (0, &cid) == -1) {
+# endif
# ifdef CLOCK_PROCESS_CPUTIME_ID
- clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts);
+ cid = CLOCK_PROCESS_CPUTIME_ID;
# elif defined(CLOCK_PROF)
- clock_gettime (CLOCK_PROF, &ts);
-# elif defined(CLOCK_VIRTUAL)
- clock_gettime (CLOCK_VIRTUAL, &ts);
+ cid = CLOCK_PROF;
# else
- clock_gettime (CLOCK_REALTIME, &ts);
+ cid = CLOCK_REALTIME;
# endif
+# ifdef HAVE_CLOCK_GETCPUCLOCKID
+ }
+# endif
+ }
+ clock_gettime (cid, &ts);
res = (double)ts.tv_sec + ts.tv_nsec / 1000000000.;
#elif defined(__APPLE__)
thread_port_t thread = mach_thread_self ();
res = info.user_time.seconds + info.system_time.seconds;
res += ((gdouble)(info.user_time.microseconds + info.system_time.microseconds)) / 1e6;
mach_port_deallocate(mach_task_self(), thread);
+#elif defined(HAVE_RUSAGE_SELF)
+ struct rusage rusage;
+ if (getrusage (RUSAGE_SELF, &rusage) != -1) {
+ res = (double) rusage.ru_utime.tv_sec +
+ (double) rusage.ru_utime.tv_usec / 1000000.0;
+ }
#else
res = clock () / (double)CLOCKS_PER_SEC;
#endif