Skip to content

Commit

Permalink
Unit tests: Retain atomic operation
Browse files Browse the repository at this point in the history
This ensures we get absolutely accurate timing.
  • Loading branch information
LorenzMeier committed Jan 22, 2019
1 parent b7bcec2 commit f21bc89
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/systemcmds/tests/hrt_test/hrt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ int HRTTest::main()

hrt_abstime t = hrt_absolute_time();
px4_usleep(1000000);
hrt_abstime elt = hrt_elapsed_time(&t);
hrt_abstime elt = hrt_elapsed_time_atomic(&t);
PX4_INFO("Elapsed time %llu in 1 sec (usleep)\n", (unsigned long long)elt);
PX4_INFO("Start time %llu\n", (unsigned long long)t);

t = hrt_absolute_time();
px4_sleep(1);
elt = hrt_elapsed_time(&t);
elt = hrt_elapsed_time_atomic(&t);
PX4_INFO("Elapsed time %llu in 1 sec (sleep)\n", (unsigned long long)elt);
PX4_INFO("Start time %llu\n", (unsigned long long)t);

Expand Down
2 changes: 1 addition & 1 deletion src/systemcmds/tests/test_microbench_hrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ ut_declare_test_c(test_microbench_hrt, MicroBenchHRT)
bool MicroBenchHRT::time_px4_hrt()
{
PERF("hrt_absolute_time()", u_64_out = hrt_absolute_time(), 1000);
PERF("hrt_elapsed_time()", u_64_out = hrt_elapsed_time(&u_64), 1000);
PERF("hrt_elapsed_time()", u_64_out = hrt_elapsed_time_atomic(&u_64), 1000);

return true;
}
Expand Down

0 comments on commit f21bc89

Please sign in to comment.