From 8ec877f40a0e8e7432f1ef2cbd1d744c793eab2d Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 29 Jul 2020 08:17:57 +0300 Subject: speed up my_timer_init() I run perf top during ./mtr testing and constantly see times() function there. It's so slow, that it has no sense to run it in a loop too many times. This patch speeds up -suite=innodb for me from 218s to 208s. 9s of times() function! --- mysys/my_rdtsc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mysys') diff --git a/mysys/my_rdtsc.c b/mysys/my_rdtsc.c index afb97553dd7..b020e224a59 100644 --- a/mysys/my_rdtsc.c +++ b/mysys/my_rdtsc.c @@ -812,7 +812,11 @@ void my_timer_init(MY_TIMER_INFO *mti) time1= my_timer_cycles(); time2= my_timer_ticks(); time3= time2; /* Avoids a Microsoft/IBM compiler warning */ +#if defined(HAVE_SYS_TIMES_H) && defined(HAVE_TIMES) + for (i= 0; i < 1000; ++i) +#else for (i= 0; i < MY_TIMER_ITERATIONS * 1000; ++i) +#endif { time3= my_timer_ticks(); if (time3 - time2 > 10) break; -- cgit v1.2.1