Skip to content

Commit

Permalink
tests: microbench uorb add sensor_gyro_fifo copy
Browse files Browse the repository at this point in the history
 - gives an idea of the cost of copying a large message
  • Loading branch information
dagar committed Apr 13, 2020
1 parent 6c1e9c6 commit aad2856
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/systemcmds/tests/test_microbench_uorb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include <uORB/Subscription.hpp>
#include <uORB/topics/sensor_accel.h>
#include <uORB/topics/sensor_gyro.h>
#include <uORB/topics/sensor_gyro_fifo.h>
#include <uORB/topics/vehicle_local_position.h>
#include <uORB/topics/vehicle_status.h>

Expand Down Expand Up @@ -107,6 +108,7 @@ class MicroBenchORB : public UnitTest
vehicle_status_s status;
vehicle_local_position_s lpos;
sensor_gyro_s gyro;
sensor_gyro_fifo_s gyro_fifo;
};

bool MicroBenchORB::run_tests()
Expand Down Expand Up @@ -136,6 +138,8 @@ void MicroBenchORB::reset()
lpos.dist_bottom_valid = rand();

gyro.timestamp = rand();

gyro_fifo.timestamp = rand();
}

ut_declare_test_c(test_microbench_uorb, MicroBenchORB)
Expand All @@ -145,6 +149,7 @@ bool MicroBenchORB::time_px4_uorb()
int fd_status = orb_subscribe(ORB_ID(vehicle_status));
int fd_lpos = orb_subscribe(ORB_ID(vehicle_local_position));
int fd_gyro = orb_subscribe(ORB_ID(sensor_gyro));
int fd_gyro_fifo = orb_subscribe(ORB_ID(sensor_gyro_fifo));

int ret = 0;
bool updated = false;
Expand All @@ -165,6 +170,11 @@ bool MicroBenchORB::time_px4_uorb()

printf("\n");

PERF("orb_check sensor_gyro_fifo", ret = orb_check(fd_gyro_fifo, &updated), 100);
PERF("orb_copy sensor_gyro_fifo", ret = orb_copy(ORB_ID(sensor_gyro_fifo), fd_gyro_fifo, &gyro_fifo), 100);

printf("\n");

PERF("orb_exists sensor_accel 0", ret = orb_exists(ORB_ID(sensor_accel), 0), 100);
PERF("orb_exists sensor_accel 1", ret = orb_exists(ORB_ID(sensor_accel), 1), 100);
PERF("orb_exists sensor_accel 2", ret = orb_exists(ORB_ID(sensor_accel), 2), 100);
Expand All @@ -180,6 +190,7 @@ bool MicroBenchORB::time_px4_uorb()
orb_unsubscribe(fd_status);
orb_unsubscribe(fd_lpos);
orb_unsubscribe(fd_gyro);
orb_unsubscribe(fd_gyro_fifo);

return true;
}
Expand Down Expand Up @@ -228,6 +239,13 @@ bool MicroBenchORB::time_px4_uorb_direct()
PERF("uORB::Subscription orb_copy sensor_gyro:3", ret = sens_gyro3.copy(&gyro), 100);
}

{
printf("\n");
uORB::Subscription sens_gyro_fifo0{ORB_ID(sensor_gyro_fifo), 0};
PERF("uORB::Subscription orb_check sensor_gyro_fifo:0", ret = sens_gyro_fifo0.updated(), 100);
PERF("uORB::Subscription orb_copy sensor_gyro_fifo:0", ret = sens_gyro_fifo0.copy(&gyro_fifo), 100);
}

return true;
}

Expand Down

0 comments on commit aad2856

Please sign in to comment.