Optimization: don't call times()->getrusage() on FreeBSD >= 7.0 when not needed.

Submitted by:	davidxu
This commit is contained in:
Alex Dupre 2010-10-26 12:08:46 +00:00
parent 40b753b266
commit cb0a4e9aae
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=263610
2 changed files with 31 additions and 1 deletions

View File

@ -7,7 +7,7 @@
PORTNAME?= mysql
PORTVERSION= 5.0.90
PORTREVISION?= 1
PORTREVISION?= 2
CATEGORIES= databases
MASTER_SITES= ${MASTER_SITE_MYSQL}
MASTER_SITE_SUBDIR= MySQL-5.0

View File

@ -0,0 +1,30 @@
--- mysys/my_clock.c.orig 2010-01-15 10:48:59.000000000 +0100
+++ mysys/my_clock.c 2010-10-26 12:29:27.000000000 +0200
@@ -16,6 +16,9 @@
#define USES_TYPES
#include "my_global.h"
+#if defined(__FreeBSD__)
+#include <osreldate.h>
+#endif
#if !defined(_MSC_VER) && !defined(__BORLANDC__) && !defined(OS2) && !defined(__NETWARE__)
#include "mysys_priv.h"
#include <sys/times.h>
@@ -23,6 +26,11 @@
long my_clock(void)
{
+#if defined(__FreeBSD__) && __FreeBSD_version__ >= 700000
+ struct timespec ts;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
+ return (ts.tv_sec * CLK_TCK + ts.tv_nsec / (1000000000 / CLK_TCK));
+#else
#if !defined(MSDOS) && !defined(__WIN__) && !defined(OS2) && !defined(__NETWARE__)
struct tms tmsbuf;
VOID(times(&tmsbuf));
@@ -30,4 +38,5 @@
#else
return clock();
#endif
+#endif
}