2 #ifndef __SFI_TESTS_H__
3 #define __SFI_TESTS_H__
6 #include <rapicorn-test.hh>
8 static void RAPICORN_UNUSED
9 sfi_init_test (
int *argcp,
char **argv)
11 sfi_init (argcp, argv, Bse::cstrings_to_vector (
"rapicorn-test-initialization=1", NULL));
12 unsigned int flags = g_log_set_always_fatal ((GLogLevelFlags) G_LOG_FATAL_MASK);
13 g_log_set_always_fatal ((GLogLevelFlags) (flags | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL));
40 #define TEST_CALIBRATION(target_ms, CODE) ({ \
41 const uint runs = 7; \
42 const double max_calibration_time = 35.0; \
43 double factor = MAX (1.0, (runs * target_ms * 2) / max_calibration_time); \
44 double ms, scaled_target_ms = target_ms / factor; \
45 GTimer *calibration_timer = false ? g_timer_new() : NULL; \
46 if (calibration_timer) \
47 g_timer_start (calibration_timer); \
48 GTimer *timer = g_timer_new(); \
55 for (i = 0; i < runs && ms >= scaled_target_ms; i++) \
57 g_timer_start (timer); \
58 for (j = 0; j < dups; j++) \
62 g_timer_stop (timer); \
63 double current_run_ms = g_timer_elapsed (timer, NULL) * 1000; \
64 ms = MIN (current_run_ms, ms); \
66 if (ms < scaled_target_ms) \
69 while (ms < scaled_target_ms); \
70 factor *= (scaled_target_ms / ms); \
71 g_timer_destroy (timer); \
72 if (calibration_timer) \
74 g_timer_stop (calibration_timer); \
75 double calibration_time_ms = g_timer_elapsed (calibration_timer, NULL) * 1000; \
76 g_timer_destroy (calibration_timer); \
77 printerr ("TEST_CALIBRATION: this system can do %d dups in %.6f milliseconds\n", \
78 guint (dups * factor), ms * factor); \
79 printerr ("TEST_CALIBRATION: calibration took %.6f milliseconds\n", \
80 calibration_time_ms); \
82 dups = MAX (uint (dups * factor), 1); \