[beast: 49/57] SFI: remove largely unused TEST_CALIBRATION, TICK, TACK macros



commit a8213b46dd99738937c052aaffcb5fdac62c98a5
Author: Tim Janik <timj gnu org>
Date:   Tue Jul 18 01:28:01 2017 +0200

    SFI: remove largely unused TEST_CALIBRATION, TICK, TACK macros
    
    Signed-off-by: Tim Janik <timj gnu org>

 sfi/sfitests.hh        |   64 ------------------------------------------------
 sfi/tests/misctests.cc |    6 ++--
 2 files changed, 3 insertions(+), 67 deletions(-)
---
diff --git a/sfi/sfitests.hh b/sfi/sfitests.hh
index de82ed8..5d8dca0 100644
--- a/sfi/sfitests.hh
+++ b/sfi/sfitests.hh
@@ -21,68 +21,4 @@ test_error (const char *format, const Args &...args)
   Bse::breakpoint();
 }
 
-#define TICK()  TOK()
-#define TACK()  TOK()
-
-/** Macro for test repetitions needed to benchmark in the order of milliseconds.
- * TEST_CALIBRATION() - This macro is used to calculate the number of
- * repetitions needed for execution of a test routine, so that the total
- * duration is long enough to be measured by a timer with millisecond
- * resolution like gettimeofday().
- * Given an upper test duration bound, this macro will return the number
- * of inner loop repetitions needed for benchmarking a piece of code.
- * Estimated run time: the calibration process should take somewhat
- * less than MIN (max_calibration_time, (target_ms * 2 * 7)) milliseconds.
- * @li @c target_ms - expected total test runtime for RUNS * dups * testfunc_time
- * @li @c max_calibration_time - expected upper bound for test calibration runtime
- * In this macro, "dups" is calculated appropriately for max_calibration_time,
- * and scaled upon return to match target_ms accordingly.
- */
-#define TEST_CALIBRATION(target_ms, CODE)              ({                              \
-  const uint   runs = 7;                                                                \
-  const double max_calibration_time = 35.0;                                             \
-  double       factor = MAX (1.0, (runs * target_ms * 2) / max_calibration_time);      \
-  double       ms, scaled_target_ms = target_ms / factor;                               \
-  GTimer       *calibration_timer = false ? g_timer_new() : NULL;                       \
-  if (calibration_timer)                                                                \
-    g_timer_start (calibration_timer);                                                  \
-  GTimer *timer = g_timer_new();                                                        \
-  uint   dups = 1;                                                                      \
-  /* birnet_thread_yield(); * on some OSes, this can stabelize the loop benches */     \
-  do                                                                                    \
-    {                                                                                   \
-      uint i, j;                                                                        \
-      ms = 9e300;                                                                       \
-      for (i = 0; i < runs && ms >= scaled_target_ms; i++)                              \
-        {                                                                               \
-          g_timer_start (timer);                                                        \
-          for (j = 0; j < dups; j++)                                                    \
-            {                                                                           \
-              CODE;                                                                     \
-            }                                                                           \
-          g_timer_stop (timer);                                                         \
-          double current_run_ms = g_timer_elapsed (timer, NULL) * 1000;                 \
-          ms = MIN (current_run_ms, ms);                                                \
-        }                                                                               \
-      if (ms < scaled_target_ms)                                                        \
-        dups *= 2;                                                                      \
-    }                                                                                   \
-  while (ms < scaled_target_ms);                                                        \
-  factor *= (scaled_target_ms / ms);                                                    \
-  g_timer_destroy (timer);                                                              \
-  if (calibration_timer)                                                                \
-    {                                                                                   \
-      g_timer_stop (calibration_timer);                                                 \
-      double calibration_time_ms = g_timer_elapsed (calibration_timer, NULL) * 1000;    \
-      g_timer_destroy (calibration_timer);                                              \
-      printerr ("TEST_CALIBRATION: this system can do %d dups in %.6f milliseconds\n",  \
-                guint (dups * factor), ms * factor);                                    \
-      printerr ("TEST_CALIBRATION: calibration took %.6f milliseconds\n",              \
-                calibration_time_ms);                                                  \
-    }                                                                                   \
-  dups = MAX (uint (dups * factor), 1);                                                 \
-  dups;                                                                                 \
-})
-
-
 #endif /* __SFI_TESTS_H__ */
diff --git a/sfi/tests/misctests.cc b/sfi/tests/misctests.cc
index 3ecd7b6..9fc0d14 100644
--- a/sfi/tests/misctests.cc
+++ b/sfi/tests/misctests.cc
@@ -156,11 +156,11 @@ test_time (void)
   t = sfi_time_system ();
   if (t < SFI_MIN_TIME || t > SFI_MAX_TIME)
     {
-      TACK ();
+      TOK ();
       t = SFI_MIN_TIME / 2 + SFI_MAX_TIME / 2;
     }
   else
-    TICK ();
+    TOK ();
   t /= SFI_USEC_FACTOR;
   t *= SFI_USEC_FACTOR;
   str = sfi_time_to_string (t);
@@ -179,7 +179,7 @@ test_time (void)
     {
       t = sfi_time_from_string_err (time_strings[i], &error);
       if (!error)
-       TICK ();
+       TOK ();
       else
        printout ("{failed to parse \"%s\": %s (got: %s)\n}", time_strings[i], error, sfi_time_to_string 
(t)); /* memleak */
       g_free (error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]