The branch main has been updated by wosch:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=e0282802a6eca08598c511d9d81aa407bd273cbe

commit e0282802a6eca08598c511d9d81aa407bd273cbe
Author:     Wolfram Schneider <wo...@freebsd.org>
AuthorDate: 2022-01-19 20:10:28 +0000
Commit:     Wolfram Schneider <wo...@freebsd.org>
CommitDate: 2022-01-20 06:43:54 +0000

    remove debug code for cpu usage
    
    I guess nobody used this in the last decade, and you can get
    similar results with the time(1) command.
---
 usr.bin/locate/locate/Makefile |  2 +-
 usr.bin/locate/locate/locate.c | 35 -----------------------------------
 2 files changed, 1 insertion(+), 36 deletions(-)

diff --git a/usr.bin/locate/locate/Makefile b/usr.bin/locate/locate/Makefile
index 7d56c57457c7..e2f5192d0b4a 100644
--- a/usr.bin/locate/locate/Makefile
+++ b/usr.bin/locate/locate/Makefile
@@ -4,7 +4,7 @@
 CONFS= locate.rc
 PROG=  locate
 SRCS=  util.c locate.c
-CFLAGS+= -I${.CURDIR} -DMMAP # -DDEBUG (print time) -O2 (10% faster)
+CFLAGS+= -I${.CURDIR} -DMMAP
 SCRIPTS=updatedb.sh mklocatedb.sh concatdb.sh
 MAN=   locate.1 locate.updatedb.8
 
diff --git a/usr.bin/locate/locate/locate.c b/usr.bin/locate/locate/locate.c
index 3499591acabc..e65109819153 100644
--- a/usr.bin/locate/locate/locate.c
+++ b/usr.bin/locate/locate/locate.c
@@ -97,15 +97,9 @@ static const char rcsid[] =
 #  include <fcntl.h>
 #endif
 
-
 #include "locate.h"
 #include "pathnames.h"
 
-#ifdef DEBUG
-#  include <sys/time.h>
-#  include <sys/types.h>
-#  include <sys/resource.h>
-#endif
 
 int f_mmap;             /* use mmap */
 int f_icase;            /* ignore case */
@@ -235,9 +229,6 @@ void
 search_fopen(char *db, char **s)
 {
        FILE *fp;
-#ifdef DEBUG
-        long t0;
-#endif
               
        /* can only read stdin once */
        if (f_stdin) { 
@@ -259,9 +250,6 @@ search_fopen(char *db, char **s)
 
        /* foreach search string ... */
        while(*s != NULL) {
-#ifdef DEBUG
-               t0 = cputime();
-#endif
                if (!f_stdin &&
                    fseek(fp, (long)0, SEEK_SET) == -1)
                        err(1, "fseek to begin of ``%s''\n", db);
@@ -270,9 +258,6 @@ search_fopen(char *db, char **s)
                        fastfind_icase(fp, *s, db);
                else
                        fastfind(fp, *s, db);
-#ifdef DEBUG
-               warnx("fastfind %ld ms", cputime () - t0);
-#endif
                s++;
        } 
        (void)fclose(fp);
@@ -291,9 +276,6 @@ search_mmap(char *db, char **s)
         int fd;
         caddr_t p;
         off_t len;
-#ifdef DEBUG
-        long t0;
-#endif
        if ((fd = open(db, O_RDONLY)) == -1 ||
            fstat(fd, &sb) == -1)
                err(1, "`%s'", db);
@@ -310,16 +292,10 @@ search_mmap(char *db, char **s)
 
        /* foreach search string ... */
        while (*s != NULL) {
-#ifdef DEBUG
-               t0 = cputime();
-#endif
                if (f_icase)
                        fastfind_mmap_icase(*s, p, len, db);
                else
                        fastfind_mmap(*s, p, len, db);
-#ifdef DEBUG
-               warnx("fastfind %ld ms", cputime () - t0);
-#endif
                s++;
        }
 
@@ -330,17 +306,6 @@ search_mmap(char *db, char **s)
 }
 #endif /* MMAP */
 
-#ifdef DEBUG
-unsigned long
-cputime ()
-{
-       struct rusage rus;
-
-       getrusage(RUSAGE_SELF, &rus);
-       return(rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000);
-}
-#endif /* DEBUG */
-
 void
 usage ()
 {

Reply via email to