void test_aclock_start_when_started(void) { aclock *ac1; double r; double ll; ac1 = aclock_create(); aut_assert("1 test_aclock_start_when_started", ac1->stopped == 0.0); aut_assert("2 test_aclock_start_when_started", !(aclock_isstopped(ac1))); aut_assert("3 test_aclock_start_when_started", ac1->elapsed == 0.0); spend_time(); aclock_elapsed(ac1); aut_assert("4 test_aclock_start_when_stopped", ac1->stopped == 0.0); aut_assert("5 test_aclock_start_when_started", !(aclock_isstopped(ac1))); aut_assert("6 test_aclock_start_when_stopped", ac1->elapsed > 0.0); spend_time(); r = aclock_start(ac1); aut_assert("7 test_aclock_start_when_started", ac1->stopped == 0.0); aut_assert("8 test_aclock_start_when_started", !(aclock_isstopped(ac1))); aut_assert("9 test_aclock_start_when_started", r == 0.0); aut_assert("10 test_aclock_start_when_started", ac1->elapsed == 0.0); spend_time(); aclock_elapsed(ac1); aut_assert("11 test_aclock_start_when_started", ac1->stopped == 0.0); aut_assert("12 test_aclock_start_when_started", !(aclock_isstopped(ac1))); aut_assert("13 test_aclock_start_when_started", ac1->elapsed > 0.0); aclock_free(ac1); }
void test_aclock_stop(void) { aclock *ac1; double r; double ll; ac1 = aclock_create(); aut_assert("0 test_aclock_stop", ac1 != NULL); aut_assert("1 test_aclock_stop", ac1->stopped == 0.0); aut_assert("2 test_aclock_stop", !(aclock_isstopped(ac1))); aut_assert("3 test_aclock_stop", ac1->elapsed == 0.0); spend_time(); r = aclock_stop(ac1); aut_assert("4 test_aclock_stop", ac1->stopped > 0.0); aut_assert("5 test_aclock_stop", aclock_isstopped(ac1)); aut_assert("6 test_aclock_stop", ac1->elapsed == r); spend_time(); aclock_elapsed(ac1); aut_assert("7 test_aclock_stop", ac1->stopped > 0.0); aut_assert("8 test_aclock_stop", aclock_isstopped(ac1)); aut_assert("9 test_aclock_stop", ac1->elapsed == r); aclock_free(ac1); }
void test_aclock_elapsed(void) { aclock *ac1; aclock *ac2; ac1 = aclock_create(); aut_assert("0 test_aclock_elapsed", ac1 != NULL); aut_assert("1 test_aclock_elapsed", ac1->stopped == 0.0); aut_assert("2 test_aclock_elapsed", ac1->elapsed == 0.0); ac2 = aclock_create(); aut_assert("3 test_aclock_elapsed", ac2->stopped == 0.0); aut_assert("4 test_aclock_elapsed", ac2->elapsed == 0.0); spend_time(); aclock_elapsed(ac1); aut_assert("5 test_aclock_elapsed", ac1->stopped == 0.0); aut_assert("6 test_aclock_elapsed", ac1->elapsed > 0.0); // No change to ac2. aut_assert("7 test_aclock_elapsed", ac2->stopped == 0.0); aut_assert("8 test_aclock_elapsed", ac2->elapsed == 0.0); aclock_free(ac1); aclock_free(ac2); }
void test_aclock_reset(void) { aclock *ac1; double r; double ll; ac1 = aclock_create(); aut_assert("0 test_aclock_reset", ac1 != NULL); aut_assert("1 test_aclock_reset", ac1->stopped == 0.0); aut_assert("2 test_aclock_reset", ac1->lastloop == ac1->started); aut_assert("3 test_aclock_reset", ac1->elapsed == 0.0); spend_time(); r = aclock_loop(ac1); aut_assert("4 test_aclock_reset", ac1->stopped == 0.0); aut_assert("5 test_aclock_reset", r > 0.0); aut_assert("6 test_aclock_reset", ac1->lastloop > 0.0); aut_assert("7 test_aclock_reset", ac1->elapsed == 0.0); r = aclock_reset(ac1); aut_assert("8 test_aclock_reset", ac1->started > 0.0); aut_assert("9 test_aclock_reset", ac1->stopped == ac1->started); aut_assert("10 test_aclock_reset", ac1->lastloop == ac1->started); aut_assert("11 test_aclock_reset", ac1->elapsed == 0.0); aclock_free(ac1); }
void test_aclock_loop(void) { aclock *ac1; double r; double ll; ac1 = aclock_create(); aut_assert("0 test_aclock_loop", ac1 != NULL); aut_assert("1 test_aclock_loop", ac1->stopped == 0.0); aut_assert("2 test_aclock_loop", ac1->lastloop == ac1->started); aut_assert("3 test_aclock_loop", ac1->elapsed == 0.0); spend_time(); r = aclock_loop(ac1); aut_assert("4 test_aclock_loop", ac1->stopped == 0.0); aut_assert("5 test_aclock_loop", r > 0.0); aut_assert("6 test_aclock_loop", ac1->lastloop > 0.0); aut_assert("7 test_aclock_loop", ac1->elapsed == 0.0); spend_time(); r = aclock_loop(ac1); aut_assert("8 test_aclock_loop", ac1->stopped == 0.0); aut_assert("9 test_aclock_loop", r > 0.0); aut_assert("10 test_aclock_loop", ac1->lastloop > 0.0); aut_assert("11 test_aclock_loop", ac1->elapsed == 0.0); spend_time(); spend_time(); r = aclock_check_loop(ac1); ll = ac1->lastloop; aut_assert("12 test_aclock_loop", ac1->stopped == 0.0); aut_assert("13 test_aclock_loop", r > 0.0); aut_assert("14 test_aclock_loop", ac1->lastloop > 0.0); aut_assert("15 test_aclock_loop", r != ac1->lastloop); aut_assert("16 test_aclock_loop", r != ll); aut_assert("17 test_aclock_loop", ac1->elapsed == 0.0); aclock_free(ac1); }
void ClockCycleCounter::compute_measure_time_lap () { start (); spend_time (); long nbr_tests = 10; for (long cnt = 0; cnt < nbr_tests; ++cnt) { stop_lap (); stop_lap (); stop_lap (); stop_lap (); } _measure_time_lap = _best_score; }
void ClockCycleCounter::compute_measure_time_total () { start (); spend_time (); Int64 best_result = 0x7FFFFFFFL; // Should be enough long nbr_tests = 100; for (long cnt = 0; cnt < nbr_tests; ++cnt) { start (); stop_lap (); const Int64 duration = _state - _start_time; best_result = min (best_result, duration); } _measure_time_total = best_result; }