|
|
|
|
@ -175,19 +175,23 @@ static void* other_thread(void* arg) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void real_phase(struct UASYNC* ua, const char* name, double minimum, double maximum) { |
|
|
|
|
uint64_t start = get_time_us(), deadline = start + 1400000, last = snapshot(ua).sample_time_us; |
|
|
|
|
uint64_t start = get_time_us(), deadline = start + 3000000; |
|
|
|
|
struct uasync_load load = snapshot(ua); |
|
|
|
|
uint64_t last = load.sample_time_us; |
|
|
|
|
uint64_t before_cpu = real_time_ns(CLOCK_THREAD_CPUTIME_ID); |
|
|
|
|
unsigned int updates = 0; |
|
|
|
|
while (get_time_us() < deadline) { |
|
|
|
|
// Полное реальное окно новой фазы и минимум десять отсчётов; лишние 400мс не требуются.
|
|
|
|
|
while ((load.sample_time_us < start + 1000000 || load.window_us < 1000000 || updates < 10) && get_time_us() < deadline) { |
|
|
|
|
uasync_poll(ua, 1000); |
|
|
|
|
uint64_t sample = snapshot(ua).sample_time_us; |
|
|
|
|
if (sample != last) { updates++; last = sample; } |
|
|
|
|
load = snapshot(ua); |
|
|
|
|
if (load.sample_time_us != last) { updates++; last = load.sample_time_us; } |
|
|
|
|
} |
|
|
|
|
struct uasync_load load = snapshot(ua); |
|
|
|
|
double reference = (double)(real_time_ns(CLOCK_THREAD_CPUTIME_ID) - before_cpu) / (get_time_us() - start) / 10; |
|
|
|
|
printf("LIVE %-18s current=%6.2f%% average=%6.2f%% reference=%6.2f%% updates=%u window=%lluus\n", |
|
|
|
|
name, load.current_percent, load.average_percent, reference, updates, (unsigned long long)load.window_us); |
|
|
|
|
printf("LIVE %-18s current=%6.2f%% average=%6.2f%% reference=%6.2f%% updates=%u window=%lluus elapsed=%lluus\n", |
|
|
|
|
name, load.current_percent, load.average_percent, reference, updates, |
|
|
|
|
(unsigned long long)load.window_us, (unsigned long long)(get_time_us() - start)); |
|
|
|
|
CHECK(load.valid); CHECK(load.window_us == 1000000); |
|
|
|
|
CHECK(load.sample_time_us >= start + 1000000); |
|
|
|
|
CHECK(load.average_percent >= minimum && load.average_percent <= maximum); |
|
|
|
|
CHECK(fabs(load.average_percent - reference) < 15); |
|
|
|
|
CHECK(updates >= 10 && updates <= 16); |
|
|
|
|
|