r20402 - gnucash/trunk/src/libqof/qof - Remove unused functions for wall clock timing.

Christian Stimming cstim at code.gnucash.org
Sat Mar 12 10:47:02 EST 2011


Author: cstim
Date: 2011-03-12 10:47:02 -0500 (Sat, 12 Mar 2011)
New Revision: 20402
Trac: http://svn.gnucash.org/trac/changeset/20402

Modified:
   gnucash/trunk/src/libqof/qof/qoflog.c
   gnucash/trunk/src/libqof/qof/qoflog.h
Log:
Remove unused functions for wall clock timing.

Facilities such as this should be used from external expert libraries.
Also, this is in the way when cleaning up some log system problems
in subsequent commits.

Modified: gnucash/trunk/src/libqof/qof/qoflog.c
===================================================================
--- gnucash/trunk/src/libqof/qof/qoflog.c	2011-03-12 15:44:51 UTC (rev 20401)
+++ gnucash/trunk/src/libqof/qof/qoflog.c	2011-03-12 15:47:02 UTC (rev 20402)
@@ -39,17 +39,6 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#else
-/* We simply define the struct timeval on our own here. */
-struct timeval
-{
-    long    tv_sec;         /* seconds */
-    long    tv_usec;        /* and microseconds */
-};
-/* include <Winsock2.h> */
-#endif
 
 #undef G_LOG_DOMAIN
 #define G_LOG_DOMAIN "qof.log"
@@ -447,123 +436,3 @@
     if (g_ascii_strncasecmp("debug", str, 5) == 0) return QOF_LOG_DEBUG;
     return QOF_LOG_DEBUG;
 }
-
-static
-struct timeval qof_clock[NUM_CLOCKS] =
-{
-    {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
-    {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
-};
-
-static
-struct timeval qof_clock_total[NUM_CLOCKS] =
-{
-    {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
-    {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
-};
-
-void
-qof_start_clock (int clockno, QofLogModule log_module, QofLogLevel log_level,
-                 const gchar *function_name, const gchar *format, ...)
-{
-    va_list ap;
-
-    if ((0 > clockno) || (NUM_CLOCKS <= clockno)) return;
-#ifdef HAVE_GETTIMEOFDAY
-    gettimeofday (&qof_clock[clockno], NULL);
-#else
-    time (&(qof_clock[clockno].tv_sec));
-    qof_clock[clockno].tv_usec = 0;
-#endif
-
-    if (!fout) qof_log_init();
-
-    fprintf (fout, "Clock %d Start: %s: ",
-             clockno, qof_log_prettify (function_name));
-
-    va_start (ap, format);
-
-    vfprintf (fout, format, ap);
-
-    va_end (ap);
-
-    fprintf (fout, "\n");
-    fflush (fout);
-}
-
-void
-qof_report_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level,
-                  const gchar *function_name, const gchar *format, ...)
-{
-    struct timeval now;
-    va_list ap;
-
-    if ((0 > clockno) || (NUM_CLOCKS <= clockno)) return;
-#ifdef HAVE_GETTIMEOFDAY
-    gettimeofday (&now, NULL);
-#else
-    time (&(now.tv_sec));
-    now.tv_usec = 0;
-#endif
-
-    /* need to borrow to make difference */
-    if (now.tv_usec < qof_clock[clockno].tv_usec)
-    {
-        now.tv_sec --;
-        now.tv_usec += 1000000;
-    }
-    now.tv_sec -= qof_clock[clockno].tv_sec;
-    now.tv_usec -= qof_clock[clockno].tv_usec;
-
-    qof_clock_total[clockno].tv_sec += now.tv_sec;
-    qof_clock_total[clockno].tv_usec += now.tv_usec;
-
-    if (!fout) qof_log_init();
-
-    fprintf (fout, "Clock %d Elapsed: %ld.%06lds %s: ",
-             clockno, (long int) now.tv_sec, (long int) now.tv_usec,
-             qof_log_prettify (function_name));
-
-    va_start (ap, format);
-
-    vfprintf (fout, format, ap);
-
-    va_end (ap);
-
-    fprintf (fout, "\n");
-    fflush (fout);
-}
-
-void
-qof_report_clock_total (gint clockno,
-                        QofLogModule log_module, QofLogLevel log_level,
-                        const gchar *function_name, const gchar *format, ...)
-{
-    va_list ap;
-
-    if ((0 > clockno) || (NUM_CLOCKS <= clockno)) return;
-
-    /* need to normalize usec */
-    while (qof_clock_total[clockno].tv_usec >= 1000000)
-    {
-        qof_clock_total[clockno].tv_sec ++;
-        qof_clock_total[clockno].tv_usec -= 1000000;
-    }
-
-    if (!fout) qof_log_init();
-
-    fprintf (fout, "Clock %d Total Elapsed: %ld.%06lds  %s: ",
-             clockno,
-             (long int) qof_clock_total[clockno].tv_sec,
-             (long int) qof_clock_total[clockno].tv_usec,
-             qof_log_prettify (function_name));
-
-    va_start (ap, format);
-
-    vfprintf (fout, format, ap);
-
-    va_end (ap);
-
-    fprintf (fout, "\n");
-    fflush (fout);
-}

Modified: gnucash/trunk/src/libqof/qof/qoflog.h
===================================================================
--- gnucash/trunk/src/libqof/qof/qoflog.h	2011-03-12 15:44:51 UTC (rev 20401)
+++ gnucash/trunk/src/libqof/qof/qoflog.h	2011-03-12 15:47:02 UTC (rev 20402)
@@ -287,78 +287,7 @@
   g_return_if_fail(test); \
 } while (0);
 
-/* -------------------------------------------------------- */
 
-/** Infrastructure to make timing measurements for critical pieces
- * of code. Used for only for performance tuning & debugging.
- */
-
-void qof_start_clock (gint clockno, QofLogModule log_module, QofLogLevel log_level,
-                      const gchar *function_name, const gchar *format, ...);
-
-void qof_report_clock (gint clockno,
-                       QofLogModule log_module,
-                       QofLogLevel log_level,
-                       const gchar *function_name,
-                       const gchar *format, ...);
-
-void qof_report_clock_total (gint clockno,
-                             QofLogModule log_module,
-                             QofLogLevel log_level,
-                             const gchar *function_name,
-                             const gchar *format, ...);
-
-#ifdef _MSC_VER
-/* Microsoft Visual Studio */
-
-/** start a particular timer */
-#define START_CLOCK(clockno,format, ...) do {        \
-  if (qof_log_check (log_module, QOF_LOG_INFO))          \
-    qof_start_clock (clockno, log_module, QOF_LOG_INFO,  \
-             G_STRFUNC, format , __VA_ARGS__);               \
-} while (0)
-
-/** report elapsed time since last report on a particular timer */
-#define REPORT_CLOCK(clockno,format, ...) do {       \
-  if (qof_log_check (log_module, QOF_LOG_INFO))          \
-    qof_report_clock (clockno, log_module, QOF_LOG_INFO, \
-             G_STRFUNC, format , __VA_ARGS__);               \
-} while (0)
-
-/** report total elapsed time since timer started */
-#define REPORT_CLOCK_TOTAL(clockno,format, ...) do {       \
-  if (qof_log_check (log_module, QOF_LOG_INFO))                \
-    qof_report_clock_total (clockno, log_module, QOF_LOG_INFO, \
-             G_STRFUNC, format , __VA_ARGS__);               \
-} while (0)
-
-
-#else /* _MSC_VER */
-
-/** start a particular timer */
-#define START_CLOCK(clockno,format, args...) do {        \
-  if (qof_log_check (log_module, QOF_LOG_INFO))          \
-    qof_start_clock (clockno, log_module, QOF_LOG_INFO,  \
-             G_STRFUNC, format , ## args);               \
-} while (0)
-
-/** report elapsed time since last report on a particular timer */
-#define REPORT_CLOCK(clockno,format, args...) do {       \
-  if (qof_log_check (log_module, QOF_LOG_INFO))          \
-    qof_report_clock (clockno, log_module, QOF_LOG_INFO, \
-             G_STRFUNC, format , ## args);               \
-} while (0)
-
-/** report total elapsed time since timer started */
-#define REPORT_CLOCK_TOTAL(clockno,format, args...) do {       \
-  if (qof_log_check (log_module, QOF_LOG_INFO))                \
-    qof_report_clock_total (clockno, log_module, QOF_LOG_INFO, \
-             G_STRFUNC, format , ## args);               \
-} while (0)
-
-#endif /* _MSC_VER */
-
-
 #endif /* _QOF_LOG_H */
 
 /** @} */



More information about the gnucash-changes mailing list