Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 8bd9fb9

Browse files
committed
initial commit for package testbench. 1) General API for generation of test cases (src/configure_test.py) 2) API implementation for let_executor (src/let_exec_bm.c)
1 parent 1f7ddb3 commit 8bd9fb9

10 files changed

Lines changed: 1151 additions & 12 deletions

File tree

rcl_executor/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2020
add_compile_options(-Wall -Wextra -Wpedantic)
2121
endif()
2222

23+
24+
# for performance tracing
25+
# see https://gitlab.com/micro-ROS/ros_tracing/ros2_perf_analysis/tree/feature/simple-analysis/scripts
26+
add_compile_options(-finstrument-functions
27+
-fplugin=/home/jst3si/micro-ros/src/instrument-attribute-gcc-plugin/instrument_attribute.so
28+
-fplugin-arg-instrument_attribute-debug)
29+
30+
set(CMAKE_VERBOSE_MAKEFILE ON)
31+
2332
#################################################
2433
# package dependencies
2534
#################################################

rcl_executor/src/let_executor.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ _rcle_print_handles(rcle_let_executor_t * executor)
4343
}
4444
}
4545

46-
rcl_ret_t
46+
rcl_ret_t __attribute__((instrument_function))
4747
rcle_let_executor_init(
4848
rcle_let_executor_t * e,
4949
rcl_context_t * context,
@@ -94,7 +94,7 @@ rcle_let_executor_init(
9494
return ret;
9595
}
9696

97-
rcl_ret_t
97+
rcl_ret_t __attribute__((instrument_function))
9898
rcle_let_executor_set_timeout(rcle_let_executor_t * executor, const uint64_t timeout_ns)
9999
{
100100
RCL_CHECK_FOR_NULL_WITH_MSG(
@@ -109,7 +109,7 @@ rcle_let_executor_set_timeout(rcle_let_executor_t * executor, const uint64_t tim
109109
return ret;
110110
}
111111

112-
rcl_ret_t
112+
rcl_ret_t __attribute__((instrument_function))
113113
rcle_let_executor_fini(rcle_let_executor_t * executor)
114114
{
115115
RCL_CHECK_FOR_NULL_WITH_MSG(
@@ -144,7 +144,7 @@ rcle_let_executor_fini(rcle_let_executor_t * executor)
144144
}
145145

146146

147-
rcl_ret_t
147+
rcl_ret_t __attribute__((instrument_function))
148148
rcle_let_executor_add_subscription(
149149
rcle_let_executor_t * executor,
150150
rcl_subscription_t * subscription,
@@ -184,7 +184,7 @@ rcle_let_executor_add_subscription(
184184
}
185185

186186

187-
rcl_ret_t
187+
rcl_ret_t __attribute__((instrument_function))
188188
rcle_let_executor_add_timer(
189189
rcle_let_executor_t * executor,
190190
rcl_timer_t * timer)
@@ -224,7 +224,7 @@ rcle_let_executor_add_timer(
224224
* - and sets executor->handles[i].data_available = true
225225
*/
226226
static
227-
rcl_ret_t
227+
rcl_ret_t __attribute__((instrument_function))
228228
_rcle_read_input_data(rcle_let_executor_t * executor, rcl_wait_set_t * wait_set, size_t i)
229229
{
230230
RCL_CHECK_ARGUMENT_FOR_NULL(executor, RCL_RET_INVALID_ARGUMENT);
@@ -289,7 +289,7 @@ _rcle_read_input_data(rcle_let_executor_t * executor, rcl_wait_set_t * wait_set,
289289
* - calls every callback of each object depending on its type
290290
*/
291291
static
292-
rcl_ret_t
292+
rcl_ret_t __attribute__((instrument_function))
293293
_rcle_execute(rcle_let_executor_t * executor, rcl_wait_set_t * wait_set, size_t i)
294294
{
295295
RCL_CHECK_ARGUMENT_FOR_NULL(executor, RCL_RET_INVALID_ARGUMENT);
@@ -374,7 +374,7 @@ _rcle_let_scheduling(rcle_let_executor_t * executor, rcl_wait_set_t * wait_set)
374374
return rc;
375375
}
376376

377-
rcl_ret_t
377+
rcl_ret_t __attribute__((instrument_function))
378378
rcle_let_executor_spin_some(rcle_let_executor_t * executor, const uint64_t timeout_ns)
379379
{
380380
rcl_ret_t rc = RCL_RET_OK;
@@ -458,11 +458,12 @@ rcle_let_executor_spin_some(rcle_let_executor_t * executor, const uint64_t timeo
458458
return rc;
459459
}
460460

461-
rcl_ret_t
461+
rcl_ret_t __attribute__((instrument_function))
462462
rcle_let_executor_spin(rcle_let_executor_t * executor)
463463
{
464464
RCL_CHECK_ARGUMENT_FOR_NULL(executor, RCL_RET_INVALID_ARGUMENT);
465465
rcl_ret_t ret = RCL_RET_OK;
466+
printf("INFO: rcl_wait timeout %ld ms\n", ((executor->timeout_ns / 1000) / 1000));
466467
while (rcl_context_is_valid(executor->context) ) {
467468
ret = rcle_let_executor_spin_some(executor, executor->timeout_ns);
468469
if (!((ret == RCL_RET_OK) || (ret == RCL_RET_TIMEOUT))) {

rcl_executor_examples/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1010
add_compile_options(-Wall -Wextra -Wpedantic)
1111
endif()
1212

13+
# for performance tracing
14+
# see https://gitlab.com/micro-ROS/ros_tracing/ros2_perf_analysis/tree/feature/simple-analysis/scripts
15+
add_compile_options(-finstrument-functions
16+
-fplugin=/home/jst3si/micro-ros/src/instrument-attribute-gcc-plugin/instrument_attribute.so
17+
-fplugin-arg-instrument_attribute-debug)
18+
19+
set(CMAKE_VERBOSE_MAKEFILE ON)
20+
1321
find_package(ament_cmake REQUIRED)
1422
find_package(rclcpp REQUIRED)
1523
find_package(std_msgs REQUIRED)

rcl_executor_examples/example_executor.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626

2727
// callback for topic "cmd_hello"
28-
void cmd_hello_callback(const void * msgin)
28+
void __attribute__((instrument_function))
29+
cmd_hello_callback(const void * msgin)
2930
{
3031
const std_msgs__msg__String * msg = (const std_msgs__msg__String *)msgin;
3132

@@ -43,7 +44,8 @@ void cmd_hello_callback(const void * msgin)
4344

4445
// callback for topic "cmd_vel"
4546
int numberMsgCmdVel = 0;
46-
void cmd_vel_callback(const void * msgin) // TwistConstPtr
47+
void __attribute__((instrument_function))
48+
cmd_vel_callback(const void * msgin) // TwistConstPtr
4749
{
4850
const geometry_msgs__msg__Twist * twist = (const geometry_msgs__msg__Twist *)msgin;
4951
numberMsgCmdVel++;
@@ -64,7 +66,8 @@ void cmd_vel_callback(const void * msgin) // TwistConstPtr
6466
}
6567

6668
// timer callback
67-
void my_timer_callback(rcl_timer_t * timer, int64_t last_call_time)
69+
void __attribute__((instrument_function))
70+
my_timer_callback(rcl_timer_t * timer, int64_t last_call_time)
6871
{
6972
// Do timer work...
7073
// Optionally reconfigure, cancel, or reset the timer...
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2+
Changelog for package rcl_executor_testbench
3+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
0.1.0 (2019-10-17)
5+
------------------
6+
* Initial version of rcl_executor_testbench.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(rcl_executor_testbench)
3+
4+
#################################################
5+
# compiler settings
6+
#################################################
7+
8+
# Default to C11
9+
if(NOT CMAKE_C_STANDARD)
10+
set(CMAKE_C_STANDARD 11)
11+
endif()
12+
13+
# Default to C++14
14+
if(NOT CMAKE_CXX_STANDARD)
15+
set(CMAKE_CXX_STANDARD 14)
16+
endif()
17+
18+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
19+
add_compile_options(-Wall -Wextra -Wpedantic)
20+
endif()
21+
22+
23+
# for performance tracing
24+
# see https://gitlab.com/micro-ROS/ros_tracing/ros2_perf_analysis/tree/feature/simple-analysis/scripts
25+
add_compile_options(-finstrument-functions
26+
-fplugin=/home/jst3si/micro-ros/src/instrument-attribute-gcc-plugin/instrument_attribute.so
27+
-fplugin-arg-instrument_attribute-debug)
28+
29+
set(CMAKE_VERBOSE_MAKEFILE ON)
30+
31+
#################################################
32+
# package dependencies
33+
#################################################
34+
35+
find_package(ament_cmake_ros REQUIRED)
36+
find_package(rcl REQUIRED)
37+
find_package(std_msgs REQUIRED)
38+
find_package(rcl_executor REQUIRED)
39+
40+
#################################################
41+
# include directories
42+
#################################################
43+
include_directories(include)
44+
45+
#################################################
46+
# targets
47+
#################################################
48+
49+
add_executable(rcl_executor_testbench src/let_exec_bm.c)
50+
ament_target_dependencies(rcl_executor_testbench rcl rcl_executor std_msgs)
51+
52+
install(TARGETS
53+
rcl_executor_testbench
54+
DESTINATION lib/${PROJECT_NAME}
55+
)
56+
57+
ament_package()

0 commit comments

Comments
 (0)