BEAST
- Free Software Audio Synthesizer and Tracker
0.9.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
sfi
sfitests.hh
Go to the documentation of this file.
1
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2
#ifndef __SFI_TESTS_H__
3
#define __SFI_TESTS_H__
4
5
#include <
sfi/sfi.hh
>
6
#include <rapicorn-test.hh>
7
8
static
void
RAPICORN_UNUSED
9
sfi_init_test (
int
*argcp,
char
**argv)
10
{
11
sfi_init (argcp, argv, RAPICORN_PRETTY_FILE, 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));
14
}
15
16
#define TICK() TOK()
17
#define TACK() TOK()
18
19
#ifndef _
20
# define _(x) (x)
21
# define Q_(x) (x)
22
# define N_(x) (x)
23
# define U_(x) (x)
24
#endif
25
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(); \
49
guint dups = 1; \
50
/* birnet_thread_yield(); * on some OSes, this can stabelize the loop benches */
\
51
do \
52
{ \
53
uint i, j; \
54
ms = 9e300; \
55
for (i = 0; i < runs && ms >= scaled_target_ms; i++) \
56
{ \
57
g_timer_start (timer); \
58
for (j = 0; j < dups; j++) \
59
{ \
60
CODE; \
61
} \
62
g_timer_stop (timer); \
63
double current_run_ms = g_timer_elapsed (timer, NULL) * 1000; \
64
ms = MIN (current_run_ms, ms); \
65
} \
66
if (ms < scaled_target_ms) \
67
dups *= 2; \
68
} \
69
while (ms < scaled_target_ms); \
70
factor *= (scaled_target_ms / ms); \
71
g_timer_destroy (timer); \
72
if (calibration_timer) \
73
{ \
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
g_printerr ("TEST_CALIBRATION: this system can do %d dups in %.6f milliseconds\n",\
78
(guint) (dups * factor), ms * factor); \
79
g_printerr ("TEST_CALIBRATION: calibration took %.6f milliseconds\n", \
80
calibration_time_ms); \
81
} \
82
dups = MAX ((uint) (dups * factor), 1); \
83
dups; \
84
})
85
86
87
#endif
/* __SFI_TESTS_H__ */
sfi.hh
Generated on Wed Sep 16 2015 09:58:48 for BEAST - Free Software Audio Synthesizer and Tracker by
1.8.9.1